I have installed Code::Blocks for Windows and want to compile C++14 code like generic lambdas but the binary version of Code::Blocks that I've installed from codeblocks.org doesn't support the flag -std=c++14
.
How do I update the compiler and enable -std=c++14
flag for Code::Blocks?
Open your project and then go Project > Build Options > Compiler Flags . You can tick boxes in the "Compiler Flags" tab, and you can write other options in the "Other Options" tab.
Run the downloaded installer. Accept the default options. Verify the Compiler's and Debugger's Path: (For CodeBlocks 13.12 For Windows) Goto "Settings" menu ⇒ "Compiler..." ⇒ In "Selected Compiler", choose "GNU GCC Compiler" ⇒ Select tab "Toolchain Executables" ⇒ Check the "Compiler's Installation Directory".
To compile your source code using C++14 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:
Now, try to compile a program with C++14 features:
#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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With