in codeblocks There isn't a C++17 option in the Build or Compiler options, only C++14 how can i enable it in codeblocks so that both coding tools and compiler support it?
-
1Pass `-std=c++17` as an option to the compiler (if using clang or gcc). – Jesper Juhl Sep 02 '17 at 18:09
-
@Basile Starynkevitch im working on a project which the new file system library of c++17 is really needed for it – amir linux Sep 02 '17 at 18:26
-
Then avoid it and use the Boost equivalent. File systems API also exist in Qt or GTK or POCO, you could use these. On Linux you could just use the existing (and stable) system calls (`readdir`, `stat`, etc...) – Basile Starynkevitch Sep 02 '17 at 18:27
-
i know but im more interested on using std and my project is cross platform – amir linux Sep 02 '17 at 18:29
-
1Then wait a few years till that stuff has been matured – Basile Starynkevitch Sep 02 '17 at 18:29
-
You could download mingw-w64 (GCC 7.2) and configure CB to use instead of the old GCC it comes with, then add the `-std=c++17` flag. – HolyBlackCat Sep 02 '17 at 19:01
-
As of now, **Codeblocks** doesn't support C++17. – Ishpreet Sep 02 '17 at 20:10
-
@ishpreet: Codeblock don't support any kind of C++; the C++ is processed by some compiler invoked by CodeBlkock – Basile Starynkevitch Sep 03 '17 at 13:31
1 Answers
Code::Blocks is not a compiler (but some glorified source code editor, sometimes calling themselves IDEs, which runs some external compiler).
You need a C++17 compiler (and once you've got one you might configure your IDE or editor to use it with the appropriate options). Try the very latest version of GCC (at least GCC 7, and perhaps wait for GCC 8) or Clang (wait for Clang5) and pass it the -std=c++17
option
Note that C++17 is the C++ standard slated to be published by the end of 2017. You may need to wait a bit (perhaps a year or two) for compilers and the standard library implementations to correctly and completely implement it.
Therefore I don't recommend using C++17 features on a project to be released soon (at end of 2017), since you are then building on β quality foundations. However, if you work on a large project to be released in 2019, you might take the risk of betting that the C++17 features you are using in it will become mature by that time.
Regarding standard libraries functions (such as std::filesystem) you'll easily find approximate equivalent (e.g. in native OS or POSIX APIs, in Boost, in Qt, in POCO, ...) that should be reasonably easy to port once C++17 implementations are common.
(I recommend using your compiler on the command line, or using make
, ninja, or some other build automation system running compiler commands; details can be operating system and compiler specific.)

- 223,805
- 18
- 296
- 547
-
1Please recommend *anything* besides `make`. A build system like CMake, which is cross-platform would be a good recommendation. – tambre Sep 02 '17 at 18:04
-
-
1Sure, it's one thing it can generate. Realistically you wouldn't want to generate Makefiles anymore, but rather Ninja files, as they're superior in every way. You can also generate project files for many different IDEs. There's something fitting for every platform and taste. – tambre Sep 02 '17 at 18:11
-
Both GCC and Clang support all C++17 **language** features on their latest releases. There are a few missing standard library things, but they are usually fairly small. – tambre Sep 02 '17 at 18:15
-
1Oh, also, Clang 4 doesn't support the `-std=c++17` flag, but Clang 5, which should be releasing this upcoming week, does. – tambre Sep 02 '17 at 18:18
-
1@tambre: If by "fairly small", you mean the FileSystem, then yes, there will only be a "few" missing features. Neither libc++ nor libstdc++ implement the filesystem as defined in C++17. – Nicol Bolas Sep 02 '17 at 18:30
-
@NicolBolas That's true. Actually `std::filesystem` is the only blocker preventing my code from compiling on both GCC and Clang (besides porting it to Linux). If I'm understanding correctly, then Clang 5, which is shipping this upcoming week, should support C++17 filesystem library in full (although some error resolutions aren't implemented). – tambre Sep 02 '17 at 18:42