echse / echse_generic

Eco-Hydrological Simulation Environment: Generic components
Other
0 stars 2 forks source link

New GNU compiler causing compilation errors #6

Open tpilz opened 7 years ago

tpilz commented 7 years ago

Hi David, I recently updated my computer which brought some problems which ECHSE. I think the behaviour of the GNU compiler must have changed. I am using version 7.1.1 20170530.

Problem 1: Nonconforming code When compiling any ECHSE angine I get the following error and note related to the generic code:

/home/tobias/apps/echse/echse_generic//core/echse_coreFunct_main.cpp: In function ‘int main(int, const char**)’: /home/tobias/apps/echse/echse_generic//core/echse_coreFunct_main.cpp:613:13: error: redeclaration of ‘except e’ [-fpermissive] except e(__PRETTY_FUNCTION__,errmsg,__FILE__,__LINE__); ^ /home/tobias/apps/echse/echse_generic//core/echse_coreFunct_main.cpp:608:22: note: ‘std::exception e’ previously declared here } catch (exception e) { Regarding -fpermissive, the compiler doc says:

Downgrade some diagnostics about nonconformant code from errors to warnings. Thus, using -fpermissive will allow some nonconforming code to compile.

That means, the compiler option -fpermissive would downgrade the error to a warning. But still I wonder why that never was an issue before. Any ideas?

Problem 2: Using namespace std This problem is related to the std namespace. This is declared for the main function, i.e. in echse_coreFunct_main.cpp, line 41: using namespace std; In my user-specific code I am using the function accumulate() of the std namespace. In doing so I never had problems before but now the compilation results in error: ‘accumulate’ was not declared in this scope double vect_sum = accumulate(w_eta_t.begin(), w_eta_t.end(), 0.); I found the following discussion on stackoverflow: stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice. They are saying, using namespace std; is considered bad practise and one should raher use std::<object name>.

However, I wonder why that compilation error never appeared before and why the compiler is not complaining about other occurences where std objects are used. Have you observed similar issues?

Cheers, Tobias

echse commented 7 years ago

Hi Thomas,

the first issue should have been resolved by the latest update of 'echse_coreFunct_main.cpp'. IMO, it was indeed inconsistent code.

Regarding the second issue, I have no idea. But I agree that always using std:: is best practice.

When I try to build an engine with my current system (Ubuntu 16.04) I get tons of other strange errors.

Best wishes, David

tpilz commented 7 years ago

Thanks David. Strange that the older compiler versions never complained.

You said you are still getting errors with Ubuntu? I switched to Ubuntu 16.04 LTS as well (due to some others problems with the recent opensuse version) but it seems to be fine. I only cannot get the GSL library running on it (to choose from various ODE solvers within my ECHSE implementations that are not finished yet) but this is another story...

tpilz commented 7 years ago

Ok, the GSL issue has been solved as well. The problem was an error in the order how GSL had been included during compilation, see https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc

Still I wonder why this never was an issue before...