To compile with some new c++ features i have to add -std=c++11 or -std=c++0x to the compile command, like: g++ -std=c++0x. As it seems the gnu compiler for my system seems to compile by default according an older standard [C++98 ?]; can't figure out what the default standard is from g++ -v,; gives a lot of info, but not about compiler version/standard.
Why is it that the compiler uses default an older standard, while it can compile as g++ -std=c++11? Why isn't this default? And is there a way to set it default, without having to use the flag?
Any ideas? I've tried to search the web but couldn't find a satisfying answer.
[I'm running with package 'Debian 4.9.2-10'.]
C++98/C++03 is the default for some compilers because C++11/C++14 has a few breaks in compatibility.
By the way, if you want to use C++11/C++14 I strongly recommend using at least GCC 5.1 or later, as earlier versions have buggy/spotty support, especially within the C++ standard library.
I actually don't know how to change the default. You can alias the command but this won't apply to automated build tools. There is a way to compile GCC such that you can change the default but I don't know how to do it.
The default for gcc is "gnu++98", which is C++98 with many amendments that were published in C++03 and with several non-portable GNU extensions (most famous is probably the variable-length arrays)
They switched their C language default from gnu89 to gnu11 in gcc 5.0, there is hope for C++ yet.
As already stated, the support for latest standards has been incomplete. (The c++0x was a temporary option pre-standard.) Besides, the majority of codebase is not written in C++14.
The GCC devs have thus options:
1. Keep the current default that compiles a lot flawlessly. User's of new language must mind their toolchain.
2. Change the default. It won't quite support what it implies, and all the maintainers of "old" projects must fix their build options.
3. Lets remove the default entirely. Everybody must use a proper flag. Fair?
Almost everybody does (or should) use some build system. All of those systems can (and do) inject (many) flags for the compiler and linker. An option like -std doesn't need to be set many times.