Root6 macro loading fails on OSX12

root [0] .L t.C
/Users/ngu/project/dbxA2/dbxA2/analysis_core/./t.C:6:12: error: expected ';' after expression
dbxParticle aa;
           ^
           ;
/Users/ngu/project/dbxA2/dbxA2/analysis_core/./t.C:6:13: error: use of undeclared identifier 'aa'
dbxParticle aa;
            ^
~~~~~~~~~~~~~~~~~~~
 cat t.C
{

gROOT->LoadMacro("dbxParticle.cpp");

dbxParticle aa;

}
~~~~~~~~~~~~~~~
but loading from cmdline works:
root [0] gROOT->LoadMacro("dbxParticle.cpp");
root [1] 
root [1] dbxParticle aa;

~~~~~~~~~~~~~~~~~~~~

How come such a basic thing can fail??

This is the solution for ROOT6. Thanks for hiding it…

R__LOAD_LIBRARY(dbxParticle_cpp)
{
dbxParticle aa;
}

Hi unelg,

Indeed, you found it! Even better yet, use

// File example.C
#include "Rtypes.h" // for R__LOAD_LIBRARY
#include "dbx/Particle.h"

R__LOAD_LIBRARY(dbxParticle_cpp)

void example() {
  dbxParticle aa;
}

i.e.

  • use a named macro
  • add the relevant includes

That allows you to compile this code, too.

Cheers, Axel.