0

Every time I use one of the new classes C++11 offers like chrono.h and compile it with GCC it warns me that C++11 functions are still experimental and must be enabled with a special flag to be usable.

Its end 2014 at the moment of writing this, how come that after atleast 3.5 years GCC is still marking C++11 as "experimental" , are, after all those years, some functions that C++11 offers us still not implemented?

If thats the case, how come?

Code :

#include <chrono>
#include <thread>
int main()
{
    std::this_thread::sleep_for(std::chrono::milliseconds(3000));
    return 0;
}

compiler line : g++ Source.cpp -o test.exe

GCC version : g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc.

GCC spits out : C:/Program Files/mingw-w64/x86_64-4.9.2-posix-seh-rt_v3-rev0/mingw64/x86_64-w64- mingw32/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires G compiler and library support for the ISO C++ 2011 standard. This support is curr ently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 comp iler options.

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122
  • 5
    Please include the version of your compiler and what compiler flags you are passing your compiler (the command line). A specific feature and source code where you use it could also be useful, as well as the actual message gcc produces in that case. – Yakk - Adam Nevraumont Nov 20 '14 at 15:39
  • This is a valid question, once you regard @Yakk's advice – davidhigh Nov 20 '14 at 16:08
  • 1
    Your compiler line does not contain `-std=c++11` above. Have you confirmed that you actually passed `-std=c++11` to generate the above error message? – Yakk - Adam Nevraumont Nov 20 '14 at 16:46
  • I don't understand, at one point you say, you are not using -std=c++11 and at another you say you do. Which is it? – luk32 Nov 20 '14 at 16:49
  • @Yakk Once I add. '-std=c++11' to the compiler options I no longer get the error/warning message but I was already aware of that. I was puzzled as to why it did give me a warning without adding it. Shouldn't the current std on GCC be C++11 already? Why is this still not the case? – Hatted Rooster Nov 20 '14 at 16:50
  • Primarily opinion-based. You claim g++ "should" use C++11 mode by default, but there are no facts that make it so, just opinions. – n. m. could be an AI Nov 20 '14 at 17:31
  • 1
    As it's already 2014, why not use the new features C++11 gives us as a default? – Hatted Rooster Nov 20 '14 at 17:32
  • 2
    @JameyD maybe it's because there's a few breaking changes, maybe it's because they don't ship with a complete standard library for C++11 (some things like `` are still missing). For these kind of questions mailiing lists and irc rooms are the best avenue to get a real answer. – PeterT Nov 20 '14 at 17:34
  • Perhaps the world is not ready for this change yet. – n. m. could be an AI Nov 20 '14 at 17:40

1 Answers1

5

Once I add. '-std=c++11' to the compiler options I no longer get the error/warning message but I was already aware of that. I was puzzled as to why it did give me a warning without adding it. Shouldn't the current std on GCC be C++11 already? Why is this still not the case?

Software and build systems out there use the defaults and expect them to remain fairly stable. GCC does not simply update the default settings every time new standards or features are available.

If you want a particular version of the standard then you should specify it explicitly.

bames53
  • 86,085
  • 15
  • 179
  • 244
  • "every time new standards are available" - lol, 1998-2011 was 13 years. If that's too much change for you, IT may not be the profession for you. – MSalters Nov 21 '14 at 22:06
  • @MSalters There have been several more standard changes than just those two, and there have been many more times besides when breaking changes have been introduced which would break builds if they were also made default. – bames53 Nov 21 '14 at 23:59
  • The only other standard was C++03 which didn't introduce new functionality, just some corrigenda. – MSalters Nov 22 '14 at 00:29
  • C++03 actually did introduce changes that could cause previously working code to stop working. Also there's C++14, soon C++17, all the C standards, and many other changes besides which could cause previously working code to break if the new behavior is made the new default. – bames53 Nov 22 '14 at 02:48