To compile your source code using the C++14 flag in Code::Blocks, you first of all need to download and install a compiler that supports C++14 features.
Here’s how you can do it on Windows:
1. Download MinGW fromĀ here (particular build) or from official site
2. Extract it to for example: C:\ (result will be C:\MinGW)
3. Open Code::Blocks
4. Go to Settings => Compiler.
5. Go to “Toolchain Executables”.
6. In the top field “Compiler’s installation directory”, change the directory to the one where you extracted the compiler. E.g C:\MinGW.
7. Change all the necessary files under “Program Files” to match the files under C:\MinGW\bin:
8. Before you hit “OK”, go to the leftmost tab “Compiler settings”.
9. Select “Compiler Flags”.
10. Right click in the list somewhere and select “New Flag”:
11. Type in the following:
12. Click “OK” and tick the box you just created:
13. Specify the debugger path. Go to “Settings” => “Debugger”, click “Defualt” on left hand side and enter the new full path of the executable:
And finally, create a new C++ project and test if it’s working:
#include <iostream> #include <string> using namespace std; auto main() -> int { auto add_two([](auto x, auto y){ return x + y; }); cout << add_two("I"s, "t"s) << " works!" << endl; }