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

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Wed, 02 Mar 2005 13:52:29 -0600


> G__add_macro("MYMACRO", "Expanded Macro");
Is done via

        G__add_macro("MYMACRO=Expanded Macro");

> 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.

Indeed. The CINT macro system is unlikely to support your case.

However, all you need to do is

        gROOT->ProcessLine("G__CINT_ENDL G4endl;");

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Jacek M. Holeczek
Sent: Wednesday, March 02, 2005 6:26 AM
To: RootTalk
Cc: 'Masaharu Goto'
Subject: RE: [ROOT] #pragma link C++ macro ...

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 - 21:09:36 MET

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