CLion disable C++98 mode in favour of C++11

大兔子大兔子 提交于 2019-12-04 13:26:45

问题


I'm trying to compile some code using C++11 only syntax in JetBrains CLion, so I wish to disable C++98 mode. I followed the instructions accordance of this StackOverflow question, but am unable to get it working.

In order to achieve this goal, I went to ALT + SHIFT + F10 and passed the argument -std=c++11 in Program Arguments.

Upon building again, C++98 mode still seems to be enabled.

/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)
                                ^

in the code

Command::Command(std::vector<std::string> cmds)
{
    for (std::string command : cmds)
    {
         addCommand(command);
    }
}

Whilst I'm fairly certain the issue lies not within my code (IdeoneC++11 versus IdeoneC++98 (4.8.1))

Image: CLion Interface

What I'd imagine is the compilation string (per comments):

C:\cygwin64\bin\cmake.exe --build C:\Users\Zarthus\.clion10\system\cmake\generated\6dd8bed\6dd8bed\Debug --target testProject -- -j 4

So it does not appear it includes my content.

I've not a lot of experience with other JetBrains IDE's, but from what I could tell they're mostly the same.

Is anyone able to reproduce this? Should I send feedback to JetBrains that this may not be working 100% (it's still an early release build)? Or am I just botching it up and is there an user error here?

Thanks!


回答1:


This has been resolved by adding add_definitions(-std=c++11) to the end of CMakeLists.txt instead of in ALT+SHIFT+F10's command line arguments.



来源:https://stackoverflow.com/questions/25899738/clion-disable-c98-mode-in-favour-of-c11

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!