Declaration of ‘s’ shadows a global declaration

Hi,
I just installed (compiled from the source code) Geant4.10.00 and root5.34.14 on a new (empty) SL6.4.
My old Geant4 code compiles but it generates many pages of warnings (see below).
Looks like the culprit line in my .cc file is this one line:

#include “TRandom3.h”

It cause this stream of complains. Perhaps you know how to make compiler happy again?
Thanks
Jan


[ 10%] Building CXX object CMakeFiles/g4simu.dir/src/DaLiKalGeneratorAction.cc.o
In file included from /usr/local/root5.34.14/include/root/TObject.h:232,
from /usr/local/root5.34.14/include/root/TNamed.h:26,
from /usr/local/root5.34.14/include/root/TRandom.h:26,
from /usr/local/root5.34.14/include/root/TRandom3.h:26,
from /home/cosy11/goodExamples/g4DLsimple-varyBfieldFunc/src/DaLiKalGeneratorAction.cc:19:
/usr/local/root5.34.14/include/root/TBuffer.h: In function ‘TBuffer& operator>>(TBuffer&, Short_t&)’:
/usr/local/root5.34.14/include/root/TBuffer.h:331: warning: declaration of ‘s’ shadows a global declaration
/usr/local/geant4.10.00-install/include/Geant4/CLHEP/Units/SystemOfUnits.h:133: warning: shadowed declaration is here
/usr/local/root5.34.14/include/root/TBuffer.h: In function ‘TBuffer& operator>>(TBuffer&, UShort_t&)’:
/usr/local/root5.34.14/include/root/TBuffer.h:332: warning: declaration of ‘s’ shadows a global declaration
/usr/local/geant4.10.00-install/include/Geant4/CLHEP/Units/SystemOfUnits.h:133: warning: shadowed declaration is here
/usr/local/root5.34.14/include/root/TBuffer.h: In function ‘TBuffer& operator>>(TBuffer&, TString&)’:
/usr/local/root5.34.14/include/root/TBuffer.h:342: warning: declaration of ‘s’ shadows a global declaration
/usr/local/geant4.10.00-install/include/Geant4/CLHEP/Units/SystemOfUnits.h:133: warning: shadowed declaration is here
/usr/local/root5.34.14/include/root/TBuffer.h: In function ‘TBuffer& operator<<(TBuffer&, Short_t)’:
/usr/local/root5.34.14/include/root/TBuffer.h:347: warning: declaration of ‘s’ shadows a global declaration
/usr/local/geant4.10.00-install/include/Geant4/CLHEP/Units/SystemOfUnits.h:133: warning: shadowed declaration is here
/usr/local/root5.34.14/include/root/TBuffer.h: In function ‘TBuffer& operator<<(TBuffer&, UShort_t)’:
/usr/local/root5.34.14/include/root/TBuffer.h:348: warning: declaration of ‘s’ shadows a global declaration
/usr/local/geant4.10.00-install/include/Geant4/CLHEP/Units/SystemOfUnits.h:133: warning: shadowed declaration is here
/usr/local/root5.34.14/include/root/TBuffer.h: In function ‘TBuffer& operator<<(TBuffer&, const TString&)’:
/usr/local/root5.34.14/include/root/TBuffer.h:358: warning: declaration of ‘s’ shadows a global declaration
/usr/local/geant4.10.00-install/include/Geant4/CLHEP/Units/SystemOfUnits.h:133: warning: shadowed declaration is here

I’m afraid we can not help you. The fact that Geant uses a name as unique and rare as … ‘s’ in the global scope does not make this name reserved for Geant only and does not mean everybody else now has to rename every identifier (note, not even in a global scope!) to avoid name clashes. Just ignore these warnings or play with compiler’s flags.

Revisiting this old thread as this is what google finds for these symptoms.
With GCC playing with the compiler flags can work as in this extract from one of my GEANT4 classes:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#include "TRandom3.h"
#include "TFile.h"
#include "TNtuple.h"
#pragma GCC diagnostic pop

Encountered the same problem recently.
For me placing ROOT headers before G4 headers solved the problem and warning does not pop up anymore.

Like this

#include “TFile.h”
#include “TTree.h”
#include “G4AnythingElse.h”