7

I'm on Ubuntu 14.04 and have g++ 4.8.5 (Ubuntu 4.8.5-2ubuntu1~14.04.1). When trying to use -std=c++14 parameter, g++ outputs: unrecognized command line option '-std=c++14'

Even when running apt-get update and apt-get upgrade, the problem is still there. What's going on there?

  • You could probably get more recent versions of gcc for your release. Check for PPAs. I'm not sure if Ubuntu does official backports. Otherwise, backporting more recent versions of gcc yourself is also a possibility. – Faheem Mitha Feb 25 '16 at 10:32
6

From the GCC website:

Because the final ISO C++14 standard was only recently published, GCC's support is experimental

To enable C++14 support, add the command-line parameter -std=c++14 to your g++ command line. Or, to enable GNU extensions in addition to C++14 extensions, add -std=gnu++14.

In your case, have you tried the -std=gnu14 option to see it that works?

C++14 features became available from GCC 4.8, so in your case you should have some support for this.

From the g++ man page, I found this:

c++1y The next revision of the ISO C++ standard, tentatively planned for 2014. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.

gnu++1y GNU dialect of -std=c++1y. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.

So it looks like the option to use may not be c++14 but c++1y instead, give it a try.


ps: I use a newer version than yours and these are the options I have for g++

$  g++ --version
g++ (GCC) 4.9.1 20140922 (Red Hat 4.9.1-10)
  • -std=c++1y will work with GCC 4.8, though, of course, the implementaiton might be incomplete. – muru Feb 25 '16 at 9:31
  • @fduff: "C++14 features became available from GCC 4.8". Not completely: C++11 and C++14 are only supported from GCC 5, due to the sad cow string. I think also std::listhas a less critical bug in earlier versions that requires size is O(n), but the standard says it should be O(1). – user877329 Jul 25 '17 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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