CLION disables C ++ 98 mode in favor of C ++ 11

I am trying to compile some code using only the C ++ 11 syntax in the JetBrains CLion, so I want to turn off the C ++ 98 mode. I followed the instructions from https://stackoverflow.com/a/3/975456/ but failed to make it work.

To achieve this, I went to ALT + SHIFT + F10 and passed the argument -std=c++11 to "Program Arguments".

When re-created, C ++ 98 mode works again.

 /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 code

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

Although I am sure that the problem is not in my code ( IdeoneC ++ 11 compared to IdeoneC ++ 98 (4.8.1) )

Image: CLion Interface

I would suggest that this is a compilation line (for comments):

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

Therefore, it does not include my content.

I don't have much experience with other JetBrains IDEs, but from what I could tell, they are basically the same.

Can anyone reproduce this? Should I send feedback to JetBrains that this might not work 100% (is this another early version)? Or am I just doing this and is there a user error?

Thanks!

+6
source share
1 answer

This was allowed by adding add_definitions(-std=c++11) at the end of CMakeLists.txt instead of the command line arguments ALT + SHIFT + F10.

+8
source

Source: https://habr.com/ru/post/975452/


All Articles