如何将 Dev-C++ 中的模式从 c++98 模式更改为支持 C++0x(基于范围)的模式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16951376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?
提问by Victor Odouard
I am just learning how to write range based for loops, but the only problem is that my compiler, Orwell Dev-C++ doesn't seem to support it in its default mode (which is c++98). How can I change this mode to another one that supports this feature (and other features of C++0x). Thanks. Also:
我只是在学习如何编写基于范围的 for 循环,但唯一的问题是我的编译器 Orwell Dev-C++ 似乎不支持它的默认模式(即 c++98)。如何将此模式更改为支持此功能(以及 C++0x 的其他功能)的另一种模式。谢谢。还:
This was the error message: [Error] range-based-for loops are not allowed in C++98 mode
这是错误消息:[Error] range-based-for loops are not allowed in C++98 mode
I run Windows 8
我运行 Windows 8
The version I have of Dev C++ is 5.3.0.3
我的 Dev C++ 版本是 5.3.0.3
And the compiler is TDM-GCC 4.6.1 64 bit.
编译器是 TDM-GCC 4.6.1 64 位。
Thanks to everyone
谢谢大家
回答by Jamin Grey
Go to Tools -> Compiler Options -> "Compiler" tab
转到工具 -> 编译器选项 -> “编译器”选项卡
Check the checkbox labeled, "Add the following commands when calling the compiler" And add in the text entry box, "-std=c++11" or if that doesn't work "-std=C++0x"
选中标记为“调用编译器时添加以下命令”的复选框,然后在文本输入框中添加“ -std=c++11”,如果不起作用,则添加“ -std=C++0x”
Should be something like that anyway, I haven't had Dev C++ installed for many years, so I had to look at some screenshots on Google to remember.
反正应该是这样的,我好多年没有安装Dev C++了,所以我不得不在谷歌上看一些截图来记住。
回答by Kapil Batham
Download from the following link http://orwelldevcpp.blogspot.in/2015/04/dev-c-511-released.html
Go to Tools->Compiler Option->Programs
从以下链接下载 http://orwelldevcpp.blogspot.in/2015/04/dev-c-511-released.html
转到工具->编译器选项->程序
and add -std=c++11
并添加 -std=c++11
see the image
看图片
回答by Phil321
In Dev C++ 5.2.0.3 it's as simple as go to Tools->Compiler Options->Settings->Code Generation and setting Language standard (-std)to ISO C++11
在 Dev C++ 5.2.0.3 中,它就像转到工具->编译器选项->设置->代码生成并将语言标准(-std)设置为ISO C++11 一样简单
回答by user2640770
Was facing the same issue in Code::Blocks. to fix the problem, in Build Options->Compiler Flags, tick the box "Have g++ follow the c++11 ISO C++ language standard [-std=c++11]"
在 Code::Blocks 中面临同样的问题。为了解决这个问题,在 Build Options->Compiler Flags 中,勾选“Have g++ follow the c++11 ISO C++ language standard [-std=c++11]”
回答by Purgoufr
By default, support for the most recent version of C++ is not enabled. It shall be explicitly enabled by going to:
默认情况下,不启用对最新版本的 C++ 的支持。应通过以下方式明确启用:
Here, select the "Settings" tab, and within it, the "Code Generation" tab. There, in "Language standard (-std)" select "ISO C++ 11":
在这里,选择“设置”选项卡,并在其中选择“代码生成”选项卡。在那里,在“语言标准(-std)”中选择“ISO C++ 11”:
Ok that. You are now ready to compile C++11!
好的。您现在已准备好编译 C++11!
回答by Gauhar Singh
In Dev-C++ 5.11 an error comes in new tab like this:
在 Dev-C++ 5.11 中,新选项卡中出现错误,如下所示:
This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the
-std=c++11
or-std=gnu++11
compiler options.
此文件需要 ISO C++ 2011 标准的编译器和库支持。此支持目前处于试验阶段,必须使用
-std=c++11
或-std=gnu++11
编译器选项启用。
For this you have to follow four simple steps:
为此,您必须遵循四个简单的步骤:
- Go to Tools Tab
- Select Compiler Options..
- Go to General tab
- Check the checkbox named "Add following commands when calling the compiler", write this statement
-std=c++11
, and then press OK
- 转到工具选项卡
- 选择编译器选项..
- 转到常规选项卡
- 选中名为“调用编译器时添加以下命令”的复选框,编写此语句
-std=c++11
,然后按 OK
Conclusion: Error is removed
结论:错误已消除