You are here

Selecting Dictionary Entries: Linkdef.h

To select who should go into a dictionary you will want to specify a Linkdef.h file when you manually invoke rootcint. It is passed as the last argument to rootcint, and it must end on Linkdef.h, LinkDef.h, or linkdef.h. E.g. My_Linkdef.h is good, Linkdef_mine.h is not.

This file contains directives to rootcint what to create a dictionary for: you select the types and functions that will be accessible from the prompt (or in general through CINT) and for I/O.

Preamble: deselection

Basically all Linkdef.h files start with this preamble:

 
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;
The first line protects the compiler from seeing the rootcint directives. These directives are in the form of
#pragma
statements; the #pragma link of all something says that by default, rootcint should not generate the dictionary for anything it saw. The nestedclasses directive tells rootcint to not ignore nested classes, i.e. classes defined inside classes like here:
 
class Outer {
public:
  class Inner {
  public:
    // we want a dictionary for this one, too!
    ...
  };
  ...
};

 

Selection

So now we have to tell rootcint what to generate the dictionary for:

 
#pragma link C++ class AliEvent+;
#pragma link C++ function StrDup;
#pragma link C++ function operator+(const TString&,const TString&);
 
#pragma link C++ global gROOT;
#pragma link C++ global gEnv;
 
#pragma link C++ enum EMessageTypes;
are examples of just that. Note the "+" after the class name: this enables an essential feature for rootcint. We would love to make it the default but in some cases we will break code - so we have to ask you to add that "+" at the end!

 

Selection by file name

Sometimes it's easier to say: I want a dictionary for everything defined in file MyHeader.h. With rootcint you would simply put
 
#pragma link C++ defined_in "subdir/MyHeader.h";
into your Linkdef.h file. Of course subdir/MyHeader.h must correspond to one of the header files you passed to rootcint!

The End

Now all that's missing is the closing

#endif /* __CINT__ */.
Here is an example Linkdef.h:
 
#ifdef __CINT__
 
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;
 
#pragma link C++ global gHtml;
 
#pragma link C++ class THtml;
#endif