2

I work on the Code::Blocks IDE but I'm currently planning to use Sublime editor + some compiler.

In C: B, I have the MinGW g++ compiler (not sure of the version).

How do I know which C++ standard (14 or 11 or the previous ones) I'm using? Also, how do I change the C++ standard and get the one I want? (I need 14 actually). Please tell for both C::B and when I'm installing the compiler separately for Sublime.

  • 1
    Specify the one you want with the `-std=` option. – Jesper Juhl Mar 08 '18 at 05:24
  • @JesperJuhl I'm extremely new to programming. I'm sorry. Can you please explain what you mean? –  Mar 08 '18 at 05:25
  • I mean, the compiler supports multiple versions of the C++ standard and which one it uses can be controlled by passing an argument to it on the commandline (or through whatever IDE invokes the compiler) - for example `g++ -std=c++14 foo.cc` compiles "foo.cc" in C++14 mode, `g++ -std=c++11 foo.cc` compiles "foo.cc" in C++11 mode. See also [the documentation](https://gcc.gnu.org/onlinedocs/) . – Jesper Juhl Mar 08 '18 at 06:01
  • Yes, I've understood. Thank you! –  Mar 08 '18 at 06:03

1 Answers1

1

C++14 should be the default for GCC since version 6.0. Before 6.0, the default is C++98. Open a command prompt and type g++ --version to see your version.

To change the version flag, go to Settings -> Compiler (or something like that) and look at the list of compiler flags. Check the one that looks like "Have g++ follow the ISO ... C++14 standard".

For other IDEs, find the compiler/build settings, which might or might not be separate for each project, look through them, and select the standard. The flag for it is --std=c++14 by the way.

This might help.

eesiraed
  • 4,626
  • 4
  • 16
  • 34