RE: "ROOT macro" definition

From: Fine, Valeri <fine_at_bnl.gov>
Date: Mon, 20 Oct 2008 09:18:02 -0400


>
> Can anybody give the exact definition of what is the "ROOT macro"?
>

"ROOT macro" is the CINT "script" as it is defined by ftp://root.cern.ch/root/doc/7CINT.pdf <ftp://root.cern.ch/root/doc/7CINT.pdf> The main difference between C++ program and CINT script (see p. 85 for details)  

  1. C++ class and other types can be defined with the CINT dictionary implicitly rather with the C++ class declaration statements.
  2. CINT dictionary can be compiled with the regular compiler and put into the "loadable at run-time" shared library (DLL)
  3. C++ class declared by CINT script can not be derived from C++ class defined by shared library
  4. The meaning of the type / variable scope is sometimes different (especially for the global variables)
  5. CINT provides some C++ language extensions. Do not use it and you are safe.
  6. Templates - can not be used unless explicitly defined by the dictionary
  7. CINT script provides the special handling for the object pointers for some C++ classes. To see what I mean try

root.exe [0] TH1F * h = new TH1F
root.exe [1] cout << h << endl;
0xa47fb88
root.exe [2] delete h
root.exe [3] cout << h << endl;
0

7. There are other to be well documented yet features.  

> For example, the definition of the class Quad in
> $ROOTSYS/quadp/Quad.cxx, is it also called macro in ROOT?
>
> And what is the difference between macro and C++ program from the point
> of view of ROOT?

The main difference is the ROOT macro can be executed without the C++ compiler. To execute the macro all types (C++ class definitions) the macro uses must be loaded into the Root/Cint dictionary first (it can be done by macro itself)  

To execute the same piece of the C++ code as a "program" no special CINT dictionary is required. However, the code must be compiled by the regular C++ compiler first.  

You can compile C++ macro (if that does not use any CINT language extensions), create the regular shared library and load it into into the active ROOT session. In this case you will deal with the "C++ program". The ROOT provides the special built-in facility to compile the ROOT macro, create and load the shared library called ACLiC. (i.e. one can convert the "macro" to the "program") see ftp://root.cern.ch/root/doc/15AddingaClass.pdf  

Hope this helps, Valeri  


From: owner-roottalk_at_root.cern.ch on behalf of Axel Naumann Sent: Mon 10/20/2008 4:10 AM
To: Arsen Hayrapetyan
Cc: roottalk_at_cern.ch
Subject: Re: [ROOT] "ROOT macro" definition

Hi Arsen,

that's a very good question - I doubt we have ever specified this completely :-) I'll give it a try.

A ROOT macro is a C++ source file that could usually (i.e. without CINT) be compiled and put into a library. This also means it should _not_ contain a function named main. Its file name should end on ".C", ".cxx", ".cpp", or ".cc" and have no spaces.

A ROOT macro used with CINT, i.e. not with ACLiC (".L MyMacro.C+"), can make use of a few extra features:
* it does not need to specify #includes for classes with a dictionary (e.g. all of ROOT's classes)
* it does not need the libraries it uses to be loaded before the first use, as long as the library containing the class has a rootmap file, * it can be written as an unnamed macro (though I would discourage anyone from doing so), where the file starts with a "{" and ends with a "}" with no function definitions in between,
* it can use an extended version of C++, e.g. 12**2 to calculate the power of a number, . instead of -> for pointer access.

The whole idea of CINT is to ease the use of C++ and to make it trivial to convert scripted files to compiled ones. You can see that these two motivations collide when talking about things like "." vs. "->": it's just invalid C++ and no compiler will ever accept it. So my recommendation is to _not_ make use of the CINT extensions.

Let me know if you need more details.

Cheers, Axel.

On 2008-10-16 13:27, Arsen Hayrapetyan wrote:
> Hello,
>
> Can anybody give the exact definition of what is the "ROOT macro"?
>
> For example, the definition of the class Quad in
> $ROOTSYS/quadp/Quad.cxx, is it also called macro in ROOT?
>
> And what is the difference between macro and C++ program from the point
> of view of ROOT?
>
> Thanks in advance,
> Arsen.
>
>
Received on Mon Oct 20 2008 - 15:18:11 CEST

This archive was generated by hypermail 2.2.0 : Tue Oct 21 2008 - 11:50:02 CEST