I’m struggling to understand how to generate rootmaps for functions. Here a short example: I have my test.h
int testFunction(int g) {
return g+1;
}
namespace testNamespace {
class testClass {
public:
int a;
int b;
};
}
and my LinkDef.h:
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ namespace testNamespace;
#pragma link C++ function testFunction;
#pragma link C++ class testNamespace::testClass;
#endif
{ decls }
namespace testNamespace { }
[ ]
# List of selected classes
class testNamespace::testClass
header test.h
# List of selected namespaces
namespace testNamespace
No trace of testFunction, and it is available on the interpreter only after explicitly loading libtest.so, also after trying different signatures like #pragma link C++ function testFunction(int);
What am I doing wrong?
What’s adding to my confusion is that none of the rootmaps of the root libraries themselves contain any functions (at least in my installation), even though they are there in the LinkDefs (https://github.com/root-project/root/blob/master/math/mathcore/inc/LinkDef_Func.h) – things like ROOT::Math::erf are still available in the interpreter, but I’d be curious to know how that works.
Ultimately I’d like to be able to use defined_in without explicitly stating all methods in the header in LinkDef.h, but I’m already happy if the explicit way works.
Thanks for looking into this.
Valentin
Good! Regarding option 1: you don’t need to build with modules, you can - as a first step - enable modules for ROOT’s dictionaries, even without compiler support. Let me know if that sounds interesting!
And
How does it not work? With namesp::func() you should be able to pragma declare namesp and then any call to namesp::func() should automatically load the corresponding library.