问题描述
我最近开始学习C ++,因为我在Linux上,我正在使用G ++编译。
I have recently started learning C++ and, since I'm on Linux, I'm compiling using G++.
现在, / p>
Now, the tutorial I'm following says
告诉我使用这个命令编译: g ++ -std = c ++ 0x MY_CODE.cpp -o MY_APP
。
and tells me to compile using this command: g++ -std=c++0x MY_CODE.cpp -o MY_APP
.
现在,我想知道, std = c ++ 0x
标志的意义是什么?是必需的,还是我可以运行 g ++ MY_CODE.cpp -o MY_APP
?
Now, what I'm wondering, what is the point of the std=c++0x
flag? Is it required, or can I just run g++ MY_CODE.cpp -o MY_APP
?
推荐答案
默认情况下,GCC编译C ++代码为 gnu ++ 98
,这是一种奇怪的方式说C ++ 98标准加上大量的gnu extenstions
By default, GCC compiles C++-code for gnu++98
, which is a fancy way of saying the C++98 standard plus lots of gnu extenstions.
您可以使用 -std =?
向编译器说明应遵循的标准。 >
不要忽略 -pedantic
,否则会违反标准。
You use -std=???
to say to the compiler what standard it should follow.
Don't omit -pedantic
though, or it will squint on standards-conformance.
您可以选择的选项:
standard with gnu extensions
c++98 gnu++98
c++03 gnu++03
c++11 (c++0x) gnu++11 (gnu++0x)
c++14 (c++1y) gnu++14 (gnu++1y)
$ b b
即将推出:
Coming up:
c++1z gnu++1z (Planned for release sometime in 2017, might even make it.)
GCC手册:
此外,请要求完整警告,因此请添加 -Wall -Wextra
。
Also, ask for full warnings, so add -Wall -Wextra
.
有预处理器定义:
- 为一些模板先决条件添加额外的编译时检查。请注意,这些支票实际上并不总是按照他们应该做的,因此已被弃用。
- 。启用库调试模式。这具有相当大的运行时间开销。
-
_GLIBCXX_DEBUG_PEDANTIC
同上,但是检查符合标准要求, / li>
_GLIBCXX_CONCEPT_CHECKS
to add additional compile-time-checks for some templates prerequisites. Beware that those checks don't actually always do what they should, and are thus deprecated._GLIBCXX_DEBUG
. Enable the libraries debug-mode. This has considerable runtime-overhead._GLIBCXX_DEBUG_PEDANTIC
Same as above, but checks against the standards requirements instead of only against the implementations.
这篇关于在G ++编译命令中包含-std = c ++ 0x的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!