RE: #pragma link C++ macro ...

From: Jacek M. Holeczek <holeczek_at_us.edu.pl>
Date: Wed, 2 Mar 2005 13:25:43 +0100 (MET)


Hi,

> > if I define the macro there it should still be visible).
>
> Yes this is true but only in ROOT 4.03/02 and later.

I did try it with 4.03/02.
It did not see/register macros defined in the LinkDef file.

> > Anyhow, is there any magic function call that registers a macro?
>
> G__add_macro("MYMACRO");

Thanks, but that is not really sufficient ... I would need a call that actually "adds" the macro and "defines" it ...

        G__add_macro("MYMACRO", "Expanded Macro");

Well, I have almost found a solution ... I am putting one line in my .cxx file which then is precompiled into a shared library ... (this line is then executed automatically during loading of the shared library ...)

----------------------------------------- ProcessLine
static int a_completely_irrelevant_variable = (
       gROOT->ProcessLine("{#define G4endl std::endl}", &a_completely_irrelevant_variable), 0);

 root [0] .L ./G4.so

 root [0] .L ./G4.so

 root [0] .L ./G4.so
 root [1] .macro
 ...
 #define G4endl 156145856
 ...
 root [2] std::endl
 (class G__CINT_ENDL)156145856



Note that ... "G__load_text" registers the macro, but ... it also changes the "std::endl" into an address ...
I would need it to stay "std::endl" ...

Any hints?

> > Also the correct syntax is
> > #pragma link MACRO ZZZ;
>
> This above syntax is indeed wrong.
> Interestingly enough the right syntax is actually:
>
> #pragma link C++ global ZZZ;

There is a note in the CINT "reference manual" that "cint handles constant value macro as global variable." Maybe that is why in simple cases this trick with "global" works.

Thanks in advance,
Best regards,
Jacek. Received on Wed Mar 02 2005 - 13:25:52 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET