本文介绍了在Code :: Blocks中启用`-std = c ++ 14`标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我已经为Windows安装了Code :: Blocks,并希望编译C ++ 14代码,比如通用lambdas,但是我已经从codeblocks.org 不支持标志 -std = c ++ 14 。 如何更新编译器并启用Code :: Blocks的 -std = c ++ 14 标志?解决方案要在Code :: Blocks中使用C ++ 14编译源代码,首先需要下载并安装一个支持 li>从此处(特定版本)或下载MinGW从官方网站更改为选择选项 将其解压缩为例如:C:\(result将为C:\MinGW) 打开Code :: Blocks 前往[设定] => [编译器]。 前往[工具链执行档]。 将目录更改为解压缩编译器的目录。例如C:\ MinGW。 更改Program Files下的所有必要文件以匹配C:\MinGW\bin下的文件: > 在您点击确定之前,请转到最左侧的选项卡编译器设置。 选择编译器标志。 为了简单起见,右键单击列表中的新标志: b $ b > 输入以下内容并点击确定,然后点击您刚刚创建的标记框: > 最后,需要指定调试器路径。转到设置=>调试器,单击左侧的Defualt,然后输入可执行文件的新完整路径: 现在,尝试编译一个有C ++ 14特性的程序: #include< iostream> #include< string> using namespace std; auto main() - > int { auto add_two([](auto x,auto y){return x + y;}); cout<< add_two(Is,ts)<< 工作! << endl; } 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? 解决方案 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:Download MinGW from here (particular build) or from official site to choose optionsExtract it to for example: C:\ (result will be C:\MinGW)Open Code::BlocksGo to Settings => Compiler.Go to "Toolchain Executables".In the top field "Compiler’s installation directory", change the directory to the one where you extracted the compiler. E.g C:\MinGW.Change all the necessary files under "Program Files" to match the files under C:\MinGW\bin:Before you hit "OK", go to the leftmost tab "Compiler settings".Select "Compiler Flags".For simplicity, right click in the list somewhere and select "New Flag":Type in the following and click "OK", and tic the box of the flag you just created:Lastly, you need to specify the debugger path. Go to "Settings" => "Debugger", click "Defualt" on left hand side and enter the new full path of the executable: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;} 这篇关于在Code :: Blocks中启用`-std = c ++ 14`标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!