It seems like in Ubuntu 18.04, the default shipped g++ (version 7.3.0) runs in C++11 compatible mode by default. I am getting some errors in my old codes which are not C++11 compatible. I installed g++-6 (version 6.4.0) and the programs are compiling fine. Is it possible to disable C++11 mode in g++-7?

  • 1
    Actually, the default mode of GCC 6 is already C++14. GCC 7 adds C++17 support; it's probably sufficient to just disable this C++17 stuff. There's no need to go back to C++11. Going back to C++98 is really massive overkill (underkill?) – MSalters Aug 10 at 12:28
  • 5
    what did you do in old programs that aren't compatible? You might have been able to do things you weren't allowed to in the first place due to bugs. In which case you aren't going to gain anything from going to c++98. – opa Aug 10 at 13:49
  • 9
    @snb: Or they used std::auto_ptr, or they used auto in its original guise, or they have now-illegal narrowing conversions, or they used export, or, or, or – Lightness Races in Orbit Aug 10 at 14:12
  • 1
  • 2
    @LightnessRacesinOrbit Most of that would have been poor practice before C++11. – opa Aug 10 at 14:15

Try adding -std=gnu++98, it was probably the default for gcc 6.4.0.

Example:

g++ -std=gnu++98 hello.cpp -o hello

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.