CLion禁用C++98模式,支持C++11
CLion disable C++98 mode in favour of C++11
我正试图在JetBrains CLion中使用仅限C++11的语法编译一些代码,所以我希望禁用C++98模式。我按照这个StackOverflow问题的说明进行了操作,但无法使其正常工作。
为了实现这个目标,我使用ALT+SHIFT+F10并在程序参数中传递参数-std=c++11
。
在再次构建时,似乎仍然启用了C++98模式。
/cygdrive/c/Users/Zarthus/Documents/test/command.cpp: In constructor 'Command::Command(std::vector<std::basic_string<char> >)':
/cygdrive/c/Users/Zarthus/Documents/test/command.cpp:25:32: error: range-based 'for' loops are not allowed in C++98 mode
for (std::string command : commands)
^
在代码中
Command::Command(std::vector<std::string> cmds)
{
for (std::string command : cmds)
{
addCommand(command);
}
}
虽然我很确定这个问题不在我的代码中(IdeoneC++11与IdeoneC++98(4.8.1))
图片:CLion接口
我想象的是编译字符串(每个注释):
C:cygwin64bincmake.exe --build C:UsersZarthus.clion10systemcmakegenerated6dd8bed6dd8bedDebug --target testProject -- -j 4
所以它似乎不包括我的内容。
我对其他JetBrains IDE没有太多经验,但据我所知,它们基本上是一样的。
有人能复制这个吗?我是否应该向JetBrains发送反馈,说这可能不是100%有效的(它仍然是早期版本)?或者我只是把它搞砸了,这里有用户错误吗?
谢谢!
这是通过将add_definitions(-std=c++11)
添加到CMakeLists.txt
的末尾而不是在ALT+SHIFT+F10的命令行参数中来解决的。
相关文章:
- MSVC是否支持C++11样式的属性而不是__declspec
- 如何检测VS C++编译器是否支持C++11?
- 支持c ++ 11的生成文件
- C++编译器不支持C++11(例如std::unique_ptr)构建OpenWrt
- 支持DirectX 11库的编译器
- GNU C 何时支持C 11,而无需明确要求
- 要使 gcc 4.8.1 支持 c++11 中的新"auto"功能?
- Solaris 上的 GNU gcc/g++ 编译器版本,支持 C++11/14
- 我如何知道我的编译器是否支持XXXXC++11功能
- 编译一个不支持c++11和.cxx文件的cuda代码需要一个带有vexcl示例的c++11
- 支持C++11的开源STL实现
- C++编译器如何支持C++11原子,但不支持C++11内存模型
- Mac 上的 Xcode 工具支持 c++11
- 如何为安卓构建 boost 作为支持 c++11 的共享库
- 带有 g++ 的 CUDA 6.5 不支持 c++11
- 完全支持C++11的Windows C++编译器(应与Qt一起使用)
- Cython 是否支持 C++11 个容器
- 如何检查特定 g++ 版本支持 C++11 的程度
- 编译器标准支持(c++11、c++14、c++17)
- 在G++版本之间切换以支持C++11