Setting CodeBlocks to C++11

Apr 2, 2017 at 7:52pm
How do I set CodeBlocks 16.01 to C++11? My selected compiler is GNU GCC Compiler. There is no option for C++11 listed in Compiler Flags under Compiler Settings. If I type -std=c++11 into Other Compiler Options, it gives me an error: unrecognized command line option "-std=c++11".
Apr 2, 2017 at 8:15pm
What version of the compiler are you using? Older versions of the compiler will not support the current standards (versions earlier than version 4.7).

Apr 2, 2017 at 8:26pm
How can I find which version of the compiler I'm using?
Apr 2, 2017 at 8:30pm
What operating system are you using?

You can try gcc --version at the command line. Or you should be able to view the version in the "Build Messages" tab of the "Log Window" of Code::Blocks.

Last edited on Apr 2, 2017 at 8:31pm
Apr 2, 2017 at 8:36pm
I'm using Windows 10. In Build Messages, it just says GNU GCC Compiler.
Apr 2, 2017 at 8:45pm
I could try gcc --version at the command line. How do you do that?
Apr 2, 2017 at 8:57pm
Open a shell prompt. (IIRC, open the Run dialogue and enter cmd, then press Return.)
Type gcc --version followed by Return into the window which appears.
Apr 2, 2017 at 9:07pm
It says 'gcc' is not recognized as an internal or external command, operable program or batch file.
Apr 2, 2017 at 9:44pm
Okay then in Code::Blocks with no projects open select compiler settings from the Settings menu. Now go to the Tool executable tab and note the Compiler's Installation Directory.

In your shell prompt change to that directory and then type in bin/gcc --version.


Apr 2, 2017 at 10:02pm
I changed to that directory, but I'm still getting an error. What did I do wrong? This is what I typed in:
C:\Program Files (x86)\CodeBlocks\MinGW> bin/gcc --version

'bin' is not recognized as an internal or external command,
operable program or batch file.
Apr 2, 2017 at 10:37pm
I don't remember very much about the Windows shell, but you should be able to get the version of GCC by compiling and running this program:

1
2
3
4
5
6
#include <iostream>
int main() { 
  std::cout << __GNUC__ << '.' 
            << __GNUC_MINOR__ << '.'
            << __GNUC_PATCHLEVEL__ << '\n';
}
Apr 3, 2017 at 1:23am
It says 4.4.1.
Topic archived. No new replies allowed.