Hi there,
I have a problem with accessing functions in
root (cint) interpretter… The problem concerns the functions that are defined inside a namespace, e.g.:
int func1()
{
return 1;
}
namespace NS {
int func2()
{
return 2;
}
}
Everything works fine if I interpret this code - unexplained things start to happen when I compile it.
I generate dictionary using rootcint, with namespace-features enabled in linkdef.h:
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ namespace NS;
#pragma link C++ nestedclass;
#pragma link C++ nestedfunction;
#pragma link C++ nestedtypedef;
#pragma link C++ function func1;
#pragma link C++ function NS::func2;
After linking to shared lib and loading the library to root
I have no problems with “func1” - i.e. I can call it or get the address of the function. For NS::func2() I strike on a problem I cannot resolve: I can call the function
(either using NS::func2() or even:
using namespace NS; func2();
) but I cannot get its address (which is equal to: cannot get its “name” completed by “TAB” on the commandline.
I have also put some minimal class in the same namespace - there is no problem with it!
(I have added it to Linkdef.h with statement like:
#pragma link C++ class NS::NSTest2;
My project (MC-TESTER) makes extensive use of ROOT and user-selectable functions - I use ROOT macros exectuted from withing MC-TESTER to set run parameters, therefore having pointer to functions is vital for me! I had no problems with non-namespaced version (I’ve just decided to move MC-TESTER to its own namespace).
My other observation is that the same problem appears when one wants to use global variables - non-namespaced work OK, while the ones defined in a namespace does not.
I work on root 03.10/00, gcc 3.3 RedHat Linux 9.0.93
I attach .tar.gz with a short example showing the problem. Has anyone any idea how to make it work?
Best regards!
Piotr Golonka