[ROOT] compilation problem

From: Stilianos Kesisoglou (kesisogl@fnal.gov)
Date: Sat Jul 31 2004 - 21:15:28 MEST


Hi,

I've noticed strange(?) behavior when creating a shared library with ACLiC,
although I am not sure if it's important or not

The following piece of code fails to compile:

#include <iostream>

#include "TROOT.h"
#include "TCanvas.h"

void Performance()
{
    if ((TCanvas*)gROOT->GetListOfCanvases()->FindObject("c1"))
{c1->Clear();} else {TCanvas *c1 = new TCanvas();}
....
}

with the following error:

root [0] .L Performance.C++
Info in <TUnixSystem::ACLiC>: creating shared library
/rooms/salon/work/kesisogl/Thesis/PhotonPointingDevelopment/RandomTracksAnal
ysis/./Performance_C.so
In file included from
/rooms/salon/work/kesisogl/Thesis/PhotonPointingDevelopment/RandomTracksAnal
ysis/fileHWpokk.h:29,
                 from
/rooms/salon/work/kesisogl/Thesis/PhotonPointingDevelopment/RandomTracksAnal
ysis/fileHWpokk.cxx:13:
/rooms/salon/work/kesisogl/Thesis/PhotonPointingDevelopment/RandomTracksAnal
ysis/Performance.C: In
   function `void Performance()':
/rooms/salon/work/kesisogl/Thesis/PhotonPointingDevelopment/RandomTracksAnal
ysis/Performance.C:16: `
   c1' undeclared (first use this function)
/rooms/salon/work/kesisogl/Thesis/PhotonPointingDevelopment/RandomTracksAnal
ysis/Performance.C:16: (Each
   undeclared identifier is reported only once for each function it appears 
   in.)
/rooms/salon/work/kesisogl/Thesis/PhotonPointingDevelopment/RandomTracksAnal
ysis/Performance.C:16: warning: unused
   variable `TCanvas*c1'
g++x:
/rooms/salon/work/kesisogl/Thesis/PhotonPointingDevelopment/RandomTracksAnal
ysis/./fileHWpokk.o: No such file or directory
Error in <ACLiC>: Compilation failed!    

If the code is written as follows:

#include <iostream>

#include "TROOT.h"
#include "TCanvas.h"

void Performance()
{

//     TCanvas *c1 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c1");
//     
//     if (c1) {c1->Clear();} else {c1 = new TCanvas();}

    if ((TCanvas*)gROOT->GetListOfCanvases()->FindObject("c1"))
{c1->Clear();} else {TCanvas *c1 = new TCanvas();}
....
}

it compiles ok. I am not sure, perhaps I am making a mistake here but
shouldn't be the same? 

Thanks!

Stelios.



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET