Opened 10 years ago

Last modified 10 years ago

#23 new defect

MMatrix does not compile

Reported by: smueller Owned by: Thomas
Priority: major Milestone: milestone:
Component: component1 Version:
Keywords: Cc:

Description

This is an email from Thomas sent on FACT Online on Sat 2014-Dec-20:

Dear colleagues,

since I always get loud complains if something in the svn doesn't compile, I take the freedom to complain as well ;)

Please fix that (it actually obviously does not comply with the standard which does ONLY allow to instatiate const-static data members in the class header. I am surprised that any compiler compiles that)

In file included from MMatrix.cc:27:0:
MMatrix.h:34:23: sorry, unimplemented: non-static data member initializers
MMatrix.h:34:23: error: ISO C++ forbids in-class initialization of non-const static member ‘fDelimiter’
MMatrix.h:39:21: sorry, unimplemented: non-static data member initializers
MMatrix.h:39:21: error: ISO C++ forbids in-class initialization of non-const static member ‘fComment’
MMatrix.h:43:25: sorry, unimplemented: non-static data member initializers
MMatrix.h:43:25: error: in-class initialization of static data member ‘fFileName’ of non-literal type
MMatrix.h:48:32: sorry, unimplemented: non-static data member initializers
MMatrix.h:48:32: error: ISO C++ forbids in-class initialization of non-const static member ‘fLineNumber’
MMatrix.cc: In member function ‘void MMatrix::ReadFile(TString)’:
MMatrix.cc:93:3: error: ‘fFileName’ was not declared in this scope
MMatrix.cc: In member function ‘double MMatrix::pedantic_strtod(std::string) const’:
MMatrix.cc:146:26: error: ‘fFileName’ was not declared in this scope
MMatrix.cc:170:26: error: ‘fFileName’ was not declared in this scope
MMatrix.cc: In member function ‘void MMatrix::print() const’:
MMatrix.cc:203:25: error: ‘fFileName’ was not declared in this scope
MMatrix.cc: In member function ‘virtual Int_t MMatrix::ReadEnv(const TEnv&, TString, Bool_t)’:
MMatrix.cc:292:46: error: ‘fFileName’ was not declared in this scope

Side remark: You cannot include time offsets in each pixels without respecting them in the calculation of the noise-window as well.

Thanks,
Thomas.

Change History (1)

comment:1 by smueller, 10 years ago

Hi Thomas, I am sorry for you running into this.

However it looks not like a problem of not sticking to a valid C++ standard but more like the problem that I am using a C++11 tool chain to create code. And in C++11 it seems to be valid to initialize non static fields of a class in the class definition.

http://stackoverflow.com/questions/13662441/c11-allows-in-class-initialization-of-non-static-and-non-const-members-what-c

We have to decide whether we want to use the almost four year old C++11 or stick to some standard before this. Maybe even the newer C++14. Since compiler errors and warnings do also give you a feeling of how to use a language, I am now already used to this. The Problem is, that I did not thought about this clashing with older standards. But how could I? Since I still learn C++ I would first have to know all previous standards to do so...

On my Ubuntu 14.04 there is a C++11 GCC-4.8.2 out of the box. It wont even complain about this in pedantic mode with all warnings transformed to errors.

Ok. So I see two solutions:

1) We stick to some older version and each developer has to install an older compiler and use this when working on MARS. MMatrix here will have to be rewritten of course.

2) We stick always to the latest C++ standard resulting in non consistent language usage in the project.

Thomas, what compiler do you use for MARS?

Merry Christmas dear all,
Sebastian

Note: See TracTickets for help on using tickets.