Namespace in my own library


ROOT Version: 6.14.06
Platform: macOS 10.14.2
Compiler: Clang (Apple LLVM version 10.0.0)


I have a namespace (AGeoUtil) for utility functions in my library, which should works like the TMath namespace. But when I try to do tab completion in a ROOT session, I get the following error after typing AGeoUtil:: and a tab.

root [0] gSystem->Load("libROBAST")
root [1] AGeoUtil::Error in <TClass::LoadClassInfo>: no interpreter information for class AGeoUtil is available even though it has a TClass initialization routine.

Error in <TClass::LoadClassInfo>: no interpreter information for class AGeoUtil is available even though it has a TClass initialization routine.

Here you can find my code related to this namespace.



How can I get rid of this error?

I copied some lines from the TMath related files but it seems that my code above are not written properly, resulting in the error.

Try:

#if defined(__MAKECINT__) || defined(__ROOTCLING__)

#pragma link C++ nestedclass;
#pragma link C++ nestedtypedef;

#pragma link C++ namespace AGeoUtil;
#pragma link C++ defined_in namespace AGeoUtil;

#pragma link C++ function AGeoUtil::MakePointToPointBBox(const char*, const TVector3&, const TVector3&, Double_t, Double_t, TGeoBBox**, TGeoCombiTrans**);
#pragma link C++ function AGeoUtil::MakePointToPointTube(const char*, const TVector3&, const TVector3&, Double_t, TGeoTube**, TGeoCombiTrans**);

#endif /* defined(__MAKECINT__) || defined(__ROOTCLING__) */

BTW. I think you could completely remove: NamespaceImp(AGeoUtil)

Thank you. But I still get the same error with the following LinkDef.h.

#if defined(__MAKECINT__)

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ nestedclass;
#pragma link C++ nestedtypedef;

#pragma link C++ namespace AGeoUtil;
#pragma link C++ defined_in namespace AGeoUtil;

#pragma link C++ function AGeoUtil::MakePointToPointBBox(const char*, const TVector3&, const TVector3&, Double_t, Double_t, TGeoBBox**, TGeoCombiTrans**);
#pragma link C++ function AGeoUtil::MakePointToPointTube(const char*, const TVector3&, const TVector3&, Double_t, TGeoTube**, TGeoCombiTrans**);

#pragma link C++ class ABorderSurfaceCondition;
#pragma link C++ class ACauchyFormula;
#pragma link C++ class ACorsikaIACTEventHeader;
#pragma link C++ class ACorsikaIACTFile;
#pragma link C++ class ACorsikaIACTRunHeader;
#pragma link C++ class AFocalSurface;
#pragma link C++ class AGeoAsphericDisk;
#pragma link C++ class AGeoBezierPcon;
#pragma link C++ class AGeoBezierPgon;
#pragma link C++ class AGeoWinstonCone2D;
#pragma link C++ class AGeoWinstonConePoly;
#pragma link C++ class AGlassCatalog;
#pragma link C++ class ALens;
#pragma link C++ class AMirror;
#pragma link C++ class AObscuration;
#pragma link C++ class AOpticalComponent;
#pragma link C++ class AOpticsManager;
#pragma link C++ class ARay;
#pragma link C++ class ARayArray;
#pragma link C++ class ARayShooter;
#pragma link C++ class ARefractiveIndex;
#pragma link C++ class ARefractiveIndexDotInfo;
#pragma link C++ class ASchottFormula;
#pragma link C++ class ASellmeierFormula;

// for automatic loading
#ifdef MAKE_MAPS
#pragma link C++ class AGeoUtil;
#endif

#endif

BTW. I think you could completely remove: NamespaceImp(AGeoUtil)

This is for old ROOT5 compatibility, because TMath.cxx says

 // Without this macro the THtml doc for TMath can not be generated

It seems there is some ROOT 6 problem with the “namespace AGeoUtil” (works fine in ROOT 5). I guess @axel could have a look at your Makefile and fix it (I suspect some “rootcling” versus “rootcint” incompatibility).

Now I understand that this is not due to my LinkDef.h but due to this automatic loading issue.

To make the tab completion works and to allow the user to use the methods inside the user’s namespace, the header file needs to be #included first.

root [0] gSystem->Load("libROBAST")

root [2] #include "AGeoUtil.h"
root [3] AGeoUtil::

works fine.

@axel, would you tell me the issue page of this ROOT-6 loading issue if it exists?

Sorry I found the issue report myself from the thread I linked.
https://sft.its.cern.ch/jira/browse/ROOT-8745

@axel Well, I thought one would not need to #include "AGeoUtil.h" when the library has the “.pcm” file generated by “rootcling”.

We cannot autoload nor autoparse functions. The usual workaround is to declare a class inside the namespace AGeoUtil and create a #pragma link C++ class statement for that.

This will be fixed by C++ modules; the upcoming v6.16 will be a preview release for those (i.e. they are coming!)

Cheers, Axel.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.