Re: problem with #ifdef __MAKECINT__

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Thu, 30 Dec 2010 10:40:41 +0100


Hi Paul,

when #include'ing a header for which you later (e.g. whe running the code) load a dictionary, CINT will have two definitions of classes in that header: interpreted and from the dictionary. That's a problem.

#ifndef __MAKECINT__ prevents the dictionary generator from seeing the #include; what you want is hiding the header from CINT (and possible providing a forward declaration instead). I.e. I believe #ifndef __CINT__ should work.

If not then please let us know and we will look at it when we're back at CERN, on Jan 5.

Cheers, Axel

On 12/28/10 5:46 PM, Paul Seyfert wrote:
> 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());
> }
> }
> ntup->Draw("mass");
> return 0;
> }
>
>
Received on Thu Dec 30 2010 - 10:40:49 CET

This archive was generated by hypermail 2.2.0 : Fri Dec 31 2010 - 05:50:01 CET