Loading namespace in macro

Dear ROOTers,
Is there “nice looking” way to load given namespaces in my macro? Lets say that I have MyLib that contains MyNamespace and MyClass. Now I have to use MyClass before calling namespace e.g.

MyClass *d = 0x0;
Int_t val  = MyNamespace::Something();

I tried to call gSystem->Load(“MyClass”) but this it doesn’t help


_ROOT Version: 6.10/80
Platform: Not Provided
Compiler: Not Provided


You can have some file, MyLib.h:

namespace MyNamespace {
  Int_t Something() {...}
}
class MyClass {...};

And in your macro, you can do

#include "MyLib.h"
void myMacro() {
  Int_t val = MyNamespace::Something();
}

Does this help?

Hi,
actually is not an option because there is no MyLib.h file, I create “MyLib” from MyNamespace MyClass and few other classes. I tried to include “raw” MyNamespace.h but it gives me error
"IncrementalExecutor::executeFunction: symbol X unresolved while linking [cling interface function]!. C++filt says that this “X” points to method in my namespace.
However thanks to you I found better (still not perfect) solution - I can include header with something like:

MyClass *completelyUselessNullPointer;

And it works.

Ah, so then perhaps https://root-forum.cern.ch/t/load-a-standalone-sharedlibrary/28306 is your best bet. I hope this helps.

1 Like

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