[FIXED] FairEvtFilter problem with c++11 [message #17510] |
Wed, 12 November 2014 18:16 |
StefanoSpataro
Messages: 2736 Registered: June 2005 Location: Torino
|
first-grade participant |
From: *to.infn.it
|
|
Trying to install pandaroot with the new external packages and git, in an Ubuntu 14.10 (gcc 4.9.1) I have seen that the code has problems with the C++11 options.
In particular:
In file included from /home/lavezzi/git/pandaroot/pgenerators/eventFilter/FairFilteredPrimaryGenerator.h:27:0,
from /home/lavezzi/git/pandaroot/pgenerators/eventFilter/FairFilteredPrimaryGenerator.cxx:1:
/home/lavezzi/git/pandaroot/pgenerators/eventFilter/FairEvtFilter.h:129:46: error: 'constexpr' needed for in-class initialization of static data member 'const Double_t FairEvtFilter::kNoChargeSpecified' of non-integral type [-fpermissive]
static const Double_t kNoChargeSpecified = -999.9;
^
pgenerators/CMakeFiles/PGen.dir/build.make:497: recipe for target 'pgenerators/CMakeFiles/PGen.dir/eventFilter/FairFilteredPrimaryGenerator.cxx.o' failed
In c++11 static const of a non-integer number is not allowed, one should use constexpr. But if I use constexpr:
[ 9%] Generating G__PGenDict.cxx
Error: Invalid type 'constexpr' in declaration of 'Double_t kNoChargeSpecified' /home/lavezzi/git/pandaroot/pgenerators/eventFilter/FairEvtFilter.h:129:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing /home/lavezzi/git/pandaroot/cbuild/pgenerators/G__PGenDict.cxx /home/lavezzi/git/pandaroot/cbuild/pgenerators/G__PGenDict.h !!!
Error: /home/lavezzi/git/fairsoft_jul14p3/externals/bin/rootcint: error loading headers...
pgenerators/CMakeFiles/PGen.dir/build.make:77: recipe for target 'pgenerators/G__PGenDict.cxx' failed
make[2]: *** [pgenerators/G__PGenDict.cxx] Error 1
Martin, can you fix this problem? This is present in several classes, including also FTS.
From some comments i read in the forum, what you are doing is a bit nasty and should be disegned in a different and safer way.
Thanks in advance.
[Updated on: Mon, 12 January 2015 12:10] Report message to a moderator
|
|
|
|
|
|
Re: FairEvtFilter problem with c++11 [message #17517 is a reply to message #17513] |
Fri, 14 November 2014 11:19 |
StefanoSpataro
Messages: 2736 Registered: June 2005 Location: Torino
|
first-grade participant |
From: *to.infn.it
|
|
I fixed in the code and committed in svn.
Simply you cannot assign the value of a static const in the header, but you need to move it to the .cxx (thanks Mohammad and Florain for the help).
A good question is why you are defining pi, instead of using TMath::Pi().
You can find below the changes I did.
pandauser@panda-VirtualBox:~/fairsoft_jul14p3/pandaroot$ svn diff fts/FtsTracking/
Index: fts/FtsTracking/PndFtsHoughTrackFinder.cxx
===================================================================
--- fts/FtsTracking/PndFtsHoughTrackFinder.cxx (revision 26438)
+++ fts/FtsTracking/PndFtsHoughTrackFinder.cxx (working copy)
@@ -4,8 +4,10 @@
ClassImp(PndFtsHoughTrackFinder);
+const Double_t PndFtsHoughTrackFinder::meinpi = 3.14159265359;
+const Double_t PndFtsHoughTrackFinder::fZLineParabola = 368.;
+const Double_t PndFtsHoughTrackFinder::fZParabolaLine = 605.;
-
PndFtsHoughTrackFinder::PndFtsHoughTrackFinder(PndFtsHoughTrackerTask *trackerTask) :
fTrackerTask(trackerTask),
Index: fts/FtsTracking/PndFtsHoughTrackFinder.h
===================================================================
--- fts/FtsTracking/PndFtsHoughTrackFinder.h (revision 26438)
+++ fts/FtsTracking/PndFtsHoughTrackFinder.h (working copy)
@@ -164,10 +164,10 @@
// std::vector<PndTrackCand> fTrackCand; // resulting track candidates, also used for returning PndTracks
- static const Double_t meinpi = 3.14159265359;
+ static const Double_t meinpi;
///< sets where the apex of the parabola is supposed to be
- static const Double_t fZLineParabola = 368.; // the value should coincide with the start of the dipole field // 368. was ok
- static const Double_t fZParabolaLine = 605.; // the value should coincide with the end of the dipole field // TODO determine this value
+ static const Double_t fZLineParabola; // the value should coincide with the start of the dipole field // 368. was ok
+ static const Double_t fZParabolaLine; // the value should coincide with the end of the dipole field // TODO determine this value
pandauser@panda-VirtualBox:~/fairsoft_jul14p3/pandaroot$ svn diff pgenerators/eventFilter/
Index: pgenerators/eventFilter/FairEvtFilter.cxx
===================================================================
--- pgenerators/eventFilter/FairEvtFilter.cxx (revision 26438)
+++ pgenerators/eventFilter/FairEvtFilter.cxx (working copy)
@@ -5,8 +5,8 @@
#include "FairEvtFilter.h"
+const Double_t FairEvtFilter::kNoChargeSpecified = -999.9;
-
// ----- Default constructor -------------------------------------------
FairEvtFilter::FairEvtFilter()
: TNamed(), fEventNr(0), fVerbose(0), fTestMode(0)
Index: pgenerators/eventFilter/FairEvtFilter.h
===================================================================
--- pgenerators/eventFilter/FairEvtFilter.h (revision 26438)
+++ pgenerators/eventFilter/FairEvtFilter.h (working copy)
@@ -126,7 +126,7 @@
TDatabasePDG* fdbPdg;
// constant holding a double number which is not a valid charge
// this serves to indicate that the value has not been specified by the user
- static const Double_t kNoChargeSpecified = -999.9;
+ static const Double_t kNoChargeSpecified;
TClonesArray* fParticleList; // list of particles in the event which was generated
Int_t fVerbose; // level of commenting output for your filter, between 0 and 12
|
|
|
|
|