11

I downloaded and built gcc 4.6.2. I find that for C++11 features, the command line option -std=c++0x is still needed. Why is that? Isn't is supposed to support it by default?

    $ g++ --version
    g++ (GCC) 4.6.2
    Copyright (C) 2011 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Nemo
  • 24,540
  • 12
  • 45
  • 61
  • 1
    Interesting question. Other compilers (VC10) chose to include the new features by default. I really wonder why they took different paths here. – ereOn Dec 23 '11 at 14:51
  • 4
    I'm more annoyed by the fact that the default isn't even `-std=c++98` – R. Martinho Fernandes Dec 23 '11 at 14:57
  • Keep It Simple, Stupid. You want to use another standard? Specify it. Or even always specify the standard to use. If that's not at your taste, use an IDE which will configure it automatically. Or reuse a Makefile additional configuration file. – Jaffa Dec 23 '11 at 15:01
  • @R.MartinhoFernandes, isn't it natural that for gnu compiler default is `gnu++98`? – Michael Krelin - hacker Dec 23 '11 at 15:02
  • 1
    @Geoffroy, it's not like the OP doesn't know how to deal with the problem. – Michael Krelin - hacker Dec 23 '11 at 15:03
  • @MichaelKrelin-hacker my comment was related to previous comments, not directly to the question :) – Jaffa Dec 23 '11 at 15:10
  • @Michael maybe. But I like my C++ compilers to compile C++ ;) – R. Martinho Fernandes Dec 23 '11 at 15:31
  • @R.MartinhoFernandes, sure one can refer you to Geoffroy's answer here :) – Michael Krelin - hacker Dec 23 '11 at 15:33
  • You can actually change the default, if you like. Just do `gcc -dumpspecs`, edit whatever options in that you like, and save the results as a file named `specs` under the `lib/gcc/..arch../..ver../` directory (or maybe that should be `libexec`?) ... but it's probably safer just to make yourself a wrapper script to add the option. – ams Dec 23 '11 at 17:02
  • possible duplicate of [When will g++ not need -std=c++0x](http://stackoverflow.com/questions/8606765/when-will-g-not-need-std-c0x) – Bo Persson Dec 23 '11 at 18:18

4 Answers4

11

Because

  • C++11 is only 4 Months old and support for it is far from being complete or tested
  • changing the default without a big announcement and preparation phase for people is not nice
  • It is not clear if the default will ever change (see -std=C99).
PlasmaHH
  • 15,673
  • 5
  • 44
  • 57
  • And let's not forget that GCC 4.6 series is nearly 9 months old, and they wouldn't have made major changes like that less than 5 months before that. (The 4.6.2 release may not be that old, but that's strictly bug fixes only.) – ams Dec 23 '11 at 16:58
  • 1
    @ams: Indeed, I was taking it as obvious, but it is probably useful to mention. – PlasmaHH Dec 23 '11 at 19:22
5

Reading GCC website:

Status of Experimental C++0x Support in GCC 4.6

Thus you can't make default something experimental. Moreover, It was before C++11 standard release, and the actual name was not defined, which explains why C++0x and not C++11.

If you're interested by GCC 4.7, it's still experimental:

Status of Experimental C++11 Support in GCC 4.7

Jaffa
  • 12,442
  • 4
  • 49
  • 101
2

It is still needed, and will probably stay this way for the foreseeable future, because C++11 has incompatibilities with C++03. Changing G++ to compile C++11 by default will break a lot of existing code.

Community
  • 1
  • 1
user1071136
  • 15,636
  • 4
  • 42
  • 61
1

I think the fact that it's called 0x gives you a hint. It's not even complete (see http://gcc.gnu.org/projects/cxx0x.html)

Michael Krelin - hacker
  • 138,757
  • 24
  • 193
  • 173