Macros in ROOT6

Hi all,

I have a question regarding the handle of macros with the new version of ROOT.

IIn ROOT5, I had a macro to load on memory my code, so I could call it several times later with different configurations. E.g.

setup.C =

[code]{
gROOT->ProcessLine (".x $ROOTCOREDIR/scripts/load_packages.C");
gROOT->LoadMacro("./plots.cxx+");

plots *p = new plots();delete p;
}[/code]

When I wanted to load root, I simply used to do “root setup.c” and then, I could call instances of the code as “p= new plots( …)” This was particularly useful for sending root batch jobs via “root -b -q setup.c run.c”.

However, in ROOT6, I cannot do that. Loading the macro via ‘argument of ROOT’ does not load the function to memory anymore, it fails when calling the instances with an "unknown type name ‘plot’ "

I recall having read that the handling of macros have changed and now it has to be done in a different way, but I could not find this way anywhere.

Do you know how I can do this now? Or do you have any other suggestion?

Thank you!

Using symbols that are only available at runtime: load libFoo; foo()
Using identifiers that are only available at runtime: gROOT->LoadMacro(“foo.h”); foo()

Hi,

But in your case we have a reasonable work-around:

#include "scripts/load_packages.C"
#include "plots.cxx"

void setup() {
  load_packages();

  plots *p = new plots();delete p;
}

Now the only remaining issue is to add $ROOTCOREDIR to your -I include path. You can do that for instance running

root -l -b -e 'gInterpreter->AddIncludePath("$ROOTCOREDIR");' setup.C

Just like we have R__LOAD_LIBRARY in the master, we probably need a R__ADD_INCLUDE_PATH and R__ADD_LIBRARY_PATH. I have created sft.its.cern.ch/jira/browse/ROOT-7269 for that.

Cheers, Axel.

Hi Axel,

your workaround worked perfectly, that was exactly what I needed.

Thanks!