Dear rooters,
I encountered a strange behaviour of CINT with #ifdef __MAKECINT__ for which I wrote a small (minimum) example.
The situation is the following (The files are in
/afs/cern.ch/user/p/pseyfert/public ):
I received a root-software package including a headerfile Zoo.h and a
shared library libZooROOT.so.
Method A:
I want to use the software package in a macro minimum.h (see below).
minimum.h includes the line gSystem->Load("Zoo/libZooROOT.so");
and works fine if I call it:
root -l
[0] .L minimum.h
[1] minimum()
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
(int)0
[2] .q
Note: this works only if minimum.h does NOT contain #include "Zoo/Zoo.h"
Method B:
I also want to use the macro compiled, i.e.:
root -l
[0] gSystem->Load("Zoo/libZooROOT.so");
[1] .L minimum.h+
Which fails unless I #include "Zoo/Zoo.h". (Still I get a number of
warnings but, the macro runs with a correct result.)
To make minimum.h usable in both ways I found that the following if
statement should help:
#ifdef __MAKECINT__ // false in method A, true in method B
#include "Zoo/Zoo.h"
#endif
Which works for method A but fails in method B. Still the error I get in
method B is different from the error I would get in method B without
these three lines.
Short:
Including these three lines does not change anything in method A (good).
Including only the include-statement makes method A fail.
Including only the include-statement is what works in method B.
Including these three lines does chane the result in method B (good)
... but not the way as including only the include-statement.(strange)
I tried root 5.27/06 and 5.28/00 both on lxplus and a local installation of 5.27/06. (Each time I rebuilt the shared library).
Has anyone an idea what I am doing wrong in the if-statement and a solution for my problem?
Cheers,
Paul
minimum.h:
#include <TChain.h>
#include <TROOT.h>
#include <TSystem.h>
#ifdef __MAKECINT__ // does not behave the way I want it to
#include "Zoo/Zoo.h" // needed in B, forbidden in A
#endif // end of if statement
#include <TNtuple.h>
class ZooP;
int minimum() {
gSystem->Load("Zoo/libZooROOT.so");
TChain* kette = new TChain("Forest");
kette->Add("output.root");
ZooObjRefArray<ZooP>* mybranch = 0;
kette->SetBranchAddress("incl_Ks",&mybranch);
TNtuple* ntup = new TNtuple("quickview","Quickview of ZooNtuple","mass");
for (unsigned int i = 0 ; i < kette->GetEntries() ; ++i) {
kette->GetEntry(i);
for (unsigned int m = 0 ; m < mybranch->size() ; ++m) {
const ZooP* candidate = (*mybranch)[m]; ntup->Fill(candidate->momentum().M());}
This archive was generated by hypermail 2.2.0 : Thu Dec 30 2010 - 11:50:01 CET