[C++基础] 在g++ 中使支持C++11

https://askubuntu.com/questions/773283/how-do-i-use-c11-with-g

This you can do by using the -std=c++11 flag. Here's an example:

g++ -std=c++11 -Wall -Wextra -Werror main.cpp -o main

This mode can be selected with the -std=c++11 command-line flag, or -std=gnu++11 to enable GNU extensions as well.(source)

See the explanation of the other flags below. I deeply believe that using at least those error flags will make your life easier in the long run. Once you have better knowledge of what your script does, you can omit warnings if needed to achieve a result but it should not be the standard. Hope this helps you. Here's a good place to start reading.

  • -Wall — enables all major warnings.
  • -Wextra — enables other important warnings.
  • -Werror — make all warnings into errors, causing compilations to fail if any warnings are reported.

猜你喜欢

转载自www.cnblogs.com/shiyublog/p/10629307.html