SFML community forums

General => General discussions => Topic started by: The Terminator on August 12, 2012, 08:31:36 pm

Title: Does Code::Blocks have support for C++11?
Post by: The Terminator on August 12, 2012, 08:31:36 pm
I am trying to use Code::Blocks for my SFML engine, but I cannot use some c++11 features such as unique_ptr. It recognizes it, but whenever I try to use it I get an error. Do I need to upgrade my gcc? If so do you guys know to what?
Title: Re: Does Code::Blocks have support for C++11?
Post by: Spirro on August 12, 2012, 08:36:19 pm
Yes.  Settings->Compiler->Compiler Flags...Look for and check the option to "Have g++ follow the C++11 ISO C++ language standard".  If that doesn't get it then also check the box above it for the C++0x standard.


EDIT:  Forgot to add that if that option isn't in your Code::Blocks install then get one of the nightly builds.  Those are the ones I use.  I also use GCC 4.7, but 4.6 and on are the versions supporting at least C++0x that I'm aware of so check your version of GCC as well with 'gcc --version' from the command prompt.
Title: Re: Does Code::Blocks have support for C++11?
Post by: binary1248 on August 12, 2012, 09:31:53 pm
EDIT:  Forgot to add that if that option isn't in your Code::Blocks install then get one of the nightly builds.
Or just add -std=c++0x to the compiler flags yourself...
Title: Re: Does Code::Blocks have support for C++11?
Post by: OniLinkPlus on August 23, 2012, 10:27:45 pm
EDIT:  Forgot to add that if that option isn't in your Code::Blocks install then get one of the nightly builds.
Or just add -std=c++0x to the compiler flags yourself...
-std=c++11 also works
Title: Re: Does Code::Blocks have support for C++11?
Post by: JayArby on August 25, 2012, 06:38:44 am
Also, just FYI, Code::Blocks is extremely extensible and can be set up to compile with just about any compiler under the sun, so actually the question is not whether Code::Blocks supports C++11, but whether your compiler does.
Title: Re: Does Code::Blocks have support for C++11?
Post by: grivdev on November 30, 2013, 08:07:13 am
I thought i had the same issue,
but it was only the "#include <memory>" statement missing... :-[
Title: Re: Does Code::Blocks have support for C++11?
Post by: Antidote on January 22, 2014, 08:21:09 am
If you're going to be using gnu tools (MinGW, or on linux), then you want to use -std=gnu++11 instead.
-std=c++11 is intermittent at best, and -std=c++0x is technically deprecated.
Title: Re: Does Code::Blocks have support for C++11?
Post by: dabbertorres on January 22, 2014, 09:58:58 am
If you're going to be using gnu tools (MinGW, or on linux), then you want to use -std=gnu++11 instead.
-std=c++11 is intermittent at best, and -std=c++0x is technically deprecated.
Some (but not all) of the gnu extensions are not standards compliant, and therefore not as portable, so keep that in mind of whether you want to use that flag or not.
Also, the gnu extensions that do not violate the standard are available with -std=c++11.

What do you mean by "-std=c++11 is intermittent at best"? I have not heard that before.
GCC has support for all but Minimal garbage collection support (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm).
Title: Re: Does Code::Blocks have support for C++11?
Post by: Antidote on January 22, 2014, 10:06:24 am
Some versions of MinGW don't have it defined, and you get an error about -std=c++11 not being a valid option.
That's why I specifically said "gnu tools", because as long as you're using gnu tools, it's portable, it's very simple to test for this using make, automake, cmake, or any other automated script.
Title: Re: Does Code::Blocks have support for C++11?
Post by: Nexus on January 22, 2014, 10:35:14 am
That's why I specifically said "gnu tools", because as long as you're using gnu tools, it's portable
Yes, and once you want to port the code to another compiler, you'll have to find all the places where it breaks and rewrite them.

Which g++ extension do you consider useful enough to write non-standard C++?
Title: Re: Does Code::Blocks have support for C++11?
Post by: dabbertorres on January 22, 2014, 12:53:27 pm
In my opinion, if you're using a compiler that is meant to be general use, and it is not standards compliant, you shouldn't be using it. Compiler's that are meant for something quite specific are the exception.

And, as nice as it'd be if gnu tools were everywhere, they aren't. :P
Title: Re: Does Code::Blocks have support for C++11?
Post by: Antidote on January 22, 2014, 08:44:05 pm
That's not what I said at all, what I said is that SOME MinGW toolchains are broken, not to use non-standard.
Title: Re: Does Code::Blocks have support for C++11?
Post by: amir ramezani on January 23, 2014, 08:00:16 am
the best option for compiler for windows is MinGW, you can get it
here (http://"http://mingw.org)
and on Linux, get GCC and binutils and compile it yourself
but for C++11, you can use -std=gnu++11 or -std=C++11
in code::blocks, you can go to project->build options->compiler settings->compiler flags->have G++ follow C++11 iso standard
or set it as the default option in the compiler settings under the options menu I think
Title: Re: Does Code::Blocks have support for C++11?
Post by: eXpl0it3r on January 23, 2014, 09:22:14 am
the best option for compiler for windows is MinGW, you can get it
here (http://"http://mingw.org)
and on Linux, get GCC and binutils and compile it yourself
but for C++11, you can use -std=gnu++11 or -std=C++11
in code::blocks, you can go to project->build options->compiler settings->compiler flags->have G++ follow C++11 iso standard
or set it as the default option in the compiler settings under the options menu I think
Look amir ramezani, I really like that you're trying to help, but 80% of your answers are just repetition of what others have already said and I've seen quite a few false statements from you. It might be better if think twice before answering something, that has already been answered or if you do so, at least make sure to provide additional and valid information. ;)

I do not advise to you the MinGW compiler from mingw.org. The original MinGW branch has quite a few flaws and misses out on features. Instead about any MinGW-w64 derivation should work (e.g. MinGW builds).

If you're going to be using gnu tools (MinGW, or on linux), then you want to use -std=gnu++11 instead.
-std=c++11 is intermittent at best, and -std=c++0x is technically deprecated.
Necroing old threads to point out "deprecated" things, is quite ironic. Of course things get deprecated over time. In 2012 -std=c++0x was certainly a valid thing and there weren't many compilers that already supported -std=c++11

I don't see a reason to use GNU extensions and 90% of the user base here, wouldn't even get close to requiring a GNU extension. Thus -std=c++11 should still be the goto option. If a compiler doesn't support it, you should move on.