Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Does Code::Blocks have support for C++11?  (Read 45142 times)

0 Members and 1 Guest are viewing this topic.

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
Does Code::Blocks have support for C++11?
« 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?
Current Projects:
Technoport

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Does Code::Blocks have support for C++11?
« Reply #1 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.
« Last Edit: August 12, 2012, 08:46:00 pm by Spirro »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Does Code::Blocks have support for C++11?
« Reply #2 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...
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Re: Does Code::Blocks have support for C++11?
« Reply #3 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
I use the latest build of SFML2

JayArby

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Does Code::Blocks have support for C++11?
« Reply #4 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.

grivdev

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Does Code::Blocks have support for C++11?
« Reply #5 on: November 30, 2013, 08:07:13 am »
I thought i had the same issue,
but it was only the "#include <memory>" statement missing... :-[

Antidote

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Does Code::Blocks have support for C++11?
« Reply #6 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.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Does Code::Blocks have support for C++11?
« Reply #7 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.

Antidote

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Does Code::Blocks have support for C++11?
« Reply #8 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.
« Last Edit: January 22, 2014, 10:12:59 am by Antidote »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Does Code::Blocks have support for C++11?
« Reply #9 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++?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Does Code::Blocks have support for C++11?
« Reply #10 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

Antidote

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Does Code::Blocks have support for C++11?
« Reply #11 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.

amir ramezani

  • Jr. Member
  • **
  • Posts: 81
  • i'm a programmer who can't see well
    • View Profile
    • download useful software!
    • Email
Re: Does Code::Blocks have support for C++11?
« Reply #12 on: January 23, 2014, 08:00:16 am »
the best option for compiler for windows is MinGW, you can get it
here
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
if you can't see well, you can't test your applications and operating system well
my game engine:
allegro game creator
my operating system:
AmirOS

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Does Code::Blocks have support for C++11?
« Reply #13 on: January 23, 2014, 09:22:14 am »
the best option for compiler for windows is MinGW, you can get it
here
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.
« Last Edit: January 23, 2014, 04:48:57 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything