Global variables in CINT


I have some shared libraries which have some variables defined like this

static const double M_test = 0.938;

How do I make it accessible to cint?

That is how do I get a value to return when I run

root [0] M_test

… assuming I have loaded the library already?


You need to create a (ROOT-)CINT “dictionary entry”, for each of your global variables, using LinkDef lines in form: #pragma link C++ global M_test;

This does not work. I in fact already had this included.

I want them to be defined globally when I first run root.

If I remove static, it works! Not exactly sure what static does here…

Now I noticed your “static const” … see, for example, … and

Ah ha.
I understand the difference now.

As a work around, I just added all the constants to a namespace instead and added the namespace to my linkdef file. Also added using blah::some_const; for each constant.
Then I just added to my rootlogon.C:

using namespace blah;

Then it works just how I want it.

Thanks for your help!