I have a macro. C file that I run in my desktop and everything is ok. When I try to run it in lxplus an error appears in one of the include files:
~/CMSSW_8_0_13/src/ScaleFactor.h:27:29: error:
variable-sized object may not be initialized
double AXISBINS [NPOINTS+1] = {};
I change the: int NPOINTS to static const int NPOINTS but the problem still there? Do anybody have an idea what I am doing wrong?
Either use (if you need to resize or if you cannot calculate the size at compile time):
std::vector<Double_t> AXISBINS(NPOINTS+1);
or use the std::array type + (constexpr as suggested by pcanal):
constexpr auto NPOINTS = 42; // or whatever value
std::array<Double_t, NPOINTS+1> AXISBINS = {}; // remove the ={} if you dont need initialization to zero
or use a C style array
constexpr auto NPOINTS = 42; // or whatever value
Double_t AXISBINS[NPOINTS+1] = {};
I would suggest not to use the C style array - it is very convenient to have a .size() function!
Thank you very much for the quick response. Doing the changes you told me the error disappear but appear others. To be more specific I had the same problem, the same error had been appeared and when I ran my macro file in my desktop (Not in cms environment). The problem had been solved when I execute the macro file by writing: .L mymacrofile.C+ instead of writting .L mymacroflie.C. So I think the problem have to do with the way I execute my macrofile.C in the cms environment. I don’t know other way to execute my macro. Why the cmsenv is different than my environment?