如何看待GCC5将C语言默认标准改为gnu11

主题信息(必填)
主题描述(最多限制在50个字符)
申请人信息(必填)
申请信息已提交审核,请注意查收邮件,我们会尽快给您反馈。
如有疑问,请联系
如今的编程是一场程序员和上帝的竞赛,程序员要开发出更大更好、傻瓜都会用到软件。而上帝在努力创造出更大更傻的傻瓜。目前为止,上帝是赢的。个人网站:。个人QQ群:、
CSDN &《程序员》编辑/记者,我的邮箱
全栈攻城狮不知道是怎么炼成的
一只文艺范的软件攻城狮,Keep Learn,Always.
个人大数据技术博客:
本月初就有消息称 GCC 5 将在本月晚些时候发布,今天开源编译器 GCC 项目组直接跳过了5.0,发布了GCC 5.1,同样是大量新特性和Bug修复。
C编译器默认使用-std=gnu11而不是-std=gnu89;
默认情况下,libstdc++ 库默认使用了全新的ABI;(详见的Runtime Library (libstdc++)一栏)
Graphite loop optimizations 不再需要 CLooG 库,只支持ISL 0.14(推荐) 或者 0.12.2,安装手册中都有详细说明;
非标准版的 C++0x traits
has_trivial_default_constructor, has_trivial_copy_constructor 和 has_trivial_copy_assign 已弃用,在接下来的版本中将移除,标准化的 C++11 traits is_trivially_default_constructible, is_trivially_copy_constructible 和 is_trivially_copy_assignable来取代;
libstdc++ 库完整支持 C++11,实验性支持 C++14;
完整支持多线程实现OpenMP 4.0;
C 和 C++支持英特尔的 Cilk Plus并行编程接口;
完整支持 Go 1.4;
支持ARM Cortex-A72和 Cortex-A17;
初步支持 Just-In-Time (JIT)编译;
正式支持DragonFlyBSD。
此外还有许多编译优化等等。
其它诸多特性及详情请点击查看发行说明。
点击查看HackerNews的讨论。
GCC(GNU Compiler Collection,GNU编译器套件),是由 GNU 开发的编程语言编译器。它是以GPL许可证所发行的自由软件,也是 GNU计划的关键部分。GCC原本作为GNU操作系统的官方编译器,现已被大多数类Unix操作系统(如Linux、BSD、Mac OS X等)采纳为标准的编译器,GCC同样适用于微软的Windows。 GCC是自由软件过程发展中的著名例子,由自由软件基金会以GPL协议发布。
GCC 原名为 GNU C 语言编译器(GNU C Compiler) ,因为它原本只能处理 C语言。GCC 很快地扩展,变得可处理 C++。后来又扩展能够支持更多编程语言,如Fortran、Pascal、Objective-C、Java、Ada、Go以及各类处理器架构上的汇编语言等,所以改名GNU编译器套件(GNU Compiler Collection)。
————————————
极客头条正式开通了微信公众号,刊选每日精华内容和最新的资讯文章。在微信搜索“csdn_geek”或扫描下方的二维码。C Dialect Options - Using the GNU Compiler Collection (GCC)
Previous:&,
3.4 Options Controlling C Dialect
The following options control the dialect of C (or languages derived
from C, such as C++, Objective-C and Objective-C++) that the compiler
-ansiIn C mode, this is equivalent to -std=c90. In C++ mode, it is
equivalent to -std=c++98.
This turns off certain features of GCC that are incompatible with ISO
C90 (when compiling C code), or of standard C++ (when compiling C++ code),
such as the asm and typeof keywords, and
predefined macros such as unix and vax that identify the
type of system you are using.
It also enables the undesirable and
rarely used ISO trigraph feature.
For the C compiler,
it disables recognition of C++ style &//& comments as well as
the inline keyword.
The alternate keywords __asm__, __extension__,
__inline__ and __typeof__ continue to work despite
You would not want to use them in an ISO C program, of
course, but it is useful to put them in header files that might be included
in compilations done with -ansi.
Alternate predefined macros
such as __unix__ and __vax__ are also available, with or
without -ansi.
The -ansi option does not cause non-ISO programs to be
rejected gratuitously.
For that, -Wpedantic is required in
addition to -ansi.
The macro __STRICT_ANSI__ is predefined when the -ansi
option is used.
Some header files may notice this macro and refrain
from declaring certain functions or defining certain macros that the
ISO standard doesn' this is to avoid interfering with any
programs that might use these names for other things.
Functions that are normally built in but do not have semantics
defined by ISO C (such as alloca and ffs) are not built-in
functions when -ansi is used.
See , for details of the functions
-std=Determine the language standard. See , for details of these standard versions.
This option
is currently only supported when compiling C or C++.
The compiler can accept several base standards, such as &c90& or
&c++98&, and GNU dialects of those standards, such as
&gnu90& or &gnu++98&.
When a base standard is specified, the
compiler accepts all programs following that standard plus those
using GNU extensions that do not contradict it.
For example,
-std=c90 turns off certain features of GCC that are
incompatible with ISO C90, such as the asm and typeof
keywords, but not other GNU extensions that do not have a meaning in
ISO C90, such as omitting the middle term of a ?:
expression. On the other hand, when a GNU dialect of a standard is
specified, all features supported by the compiler are enabled, even when
those features change the meaning of the base standard.
As a result, some
strict-conforming programs may be rejected.
The particular standard
is used by -Wpedantic to identify which features are GNU
extensions given that version of the standard. For example
-std=gnu90 -Wpedantic warns about C++ style &//&
comments, while -std=gnu99 -Wpedantic does not.
A value for this opt possible values are
&c90&&c89&&iso&Support all ISO C90 programs (certain GNU extensions that conflict
with ISO C90 are disabled). Same as -ansi for C code.
&iso&ISO C90 as modified in amendment 1.
&c99&&c9x&&iso&&isox&ISO C99.
This standard is substantially completely supported, modulo
bugs and floating-point issues
(mainly but not entirely relating to optional C99 features from
Annexes F and G).
for more information.
names &c9x& and &isox& are deprecated.
&c11&&c1x&&iso&ISO C11, the 2011 revision of the ISO C standard.
This standard is
substantially completely supported, modulo bugs, floating-point issues
(mainly but not entirely relating to optional C11 features from
Annexes F and G) and the optional Annexes K (Bounds-checking
interfaces) and L (Analyzability).
The name &c1x& is deprecated.
&gnu90&&gnu89&GNU dialect of ISO C90 (including some C99 features).
&gnu99&&gnu9x&GNU dialect of ISO C99.
The name &gnu9x& is deprecated.
&gnu11&&gnu1x&GNU dialect of ISO C11.
This is the default for C code.
The name &gnu1x& is deprecated.
&c++98&&c++03&The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
additional defect reports. Same as -ansi for C++ code.
&gnu++98&&gnu++03&GNU dialect of -std=c++98.
&c++11&&c++0x&The 2011 ISO C++ standard plus amendments.
The name &c++0x& is deprecated.
&gnu++11&&gnu++0x&GNU dialect of -std=c++11.
The name &gnu++0x& is deprecated.
&c++14&&c++1y&The 2014 ISO C++ standard plus amendments.
The name &c++1y& is deprecated.
&gnu++14&&gnu++1y&GNU dialect of -std=c++14.
This is the default for C++ code.
The name &gnu++1y& is deprecated.
&c++1z&The next revision of the ISO C++ standard, tentatively planned for
Support is highly experimental, and will almost certainly
change in incompatible ways in future releases.
&gnu++1z&GNU dialect of -std=c++1z.
Support is highly experimental,
and will almost certainly change in incompatible ways in future
-fgnu89-inlineThe option -fgnu89-inline tells GCC to use the traditional
GNU semantics for inline functions when in C99 mode.
Using this option is roughly equivalent to adding the
gnu_inline function attribute to all inline functions
The option -fno-gnu89-inline explicitly tells GCC to use the
C99 semantics for inline when in C99 or gnu99 mode (i.e., it
specifies the default behavior).
This option is not supported in -std=c90 or
-std=gnu90 mode.
The preprocessor macros __GNUC_GNU_INLINE__ and
__GNUC_STDC_INLINE__ may be used to check which semantics are
in effect for inline functions.
-aux-info filenameOutput to the given filename prototyped declarations for all functions
declared and/or defined in a translation unit, including those in header
This option is silently ignored in any language other than C.
Besides declarations, the file indicates, in comments, the origin of
each declaration (source file and line), whether the declaration was
implicit, prototyped or unprototyped (&I&, &N& for new or
&O& for old, respectively, in the first character after the line
number and the colon), and whether it came from a declaration or a
definition (&C& or &F&, respectively, in the following
character).
In the case of function definitions, a K&R-style list of
arguments followed by their declarations is also provided, inside
comments, after the declaration.
-fallow-parameterless-variadic-functionsAccept variadic functions without named parameters.
Although it is possible to define such a function, this is not very
useful as it is not possible to read the arguments.
This is only
supported for C as this construct is allowed by C++.
-fno-asmDo not recognize asm, inline or typeof as a
keyword, so that code can use these words as identifiers.
You can use
the keywords __asm__, __inline__ and __typeof__
-ansi implies -fno-asm.
In C++, this switch only affects the typeof keyword, since
asm and inline are standard keywords.
You may want to
use the -fno-gnu-keywords flag instead, which has the same
In C99 mode (-std=c99 or -std=gnu99), this
switch only affects the asm and typeof keywords, since
inline is a standard keyword in ISO C99.
-fno-builtin-fno-builtin-functionDon't recognize built-in functions that do not begin with
&__builtin_& as prefix.
See , for details of the functions affected,
including those which are not built-in functions when -ansi or
-std options for strict ISO C conformance are used because they
do not have an ISO standard meaning.
GCC normally generates special code to handle certain built-in functions
for instance, calls to alloca may become single
instructions which adjust the stack directly, and calls to memcpy
may become inline copy loops.
The resulting code is often both smaller
and faster, but since the function calls no longer appear as such, you
cannot set a breakpoint on those calls, nor can you change the behavior
of the functions by linking with a different library.
In addition,
when a function is recognized as a built-in function, GCC may use
information about that function to warn about problems with calls to
that function, or to generate more efficient code, even if the
resulting code still contains calls to that function.
For example,
warnings are given with -Wformat for bad calls to
printf when printf is built in and strlen is
known not to modify global memory.
With the -fno-builtin-function option
only the built-in function function is
function must not begin with &__builtin_&.
function is named that is not built-in in this version of GCC, this
option is ignored.
There is no corresponding
-fbuiltin-function if you wish to enable
built-in functions selectively when using -fno-builtin or
-ffreestanding, you may define macros such as:
#define abs(n)
__builtin_abs ((n))
#define strcpy(d, s)
__builtin_strcpy ((d), (s))
Assert that compilation targets a hosted environment.
This implies
-fbuiltin.
A hosted environment is one in which the
entire standard library is available, and in which main has a return
type of int.
Examples are nearly everything except a kernel.
This is equivalent to -fno-freestanding.
-ffreestanding
Assert that compilation targets a freestanding environment.
implies -fno-builtin.
A freestanding environment
is one in which the standard library may not exist, and program startup may
not necessarily be at main.
The most obvious example is an OS kernel.
This is equivalent to -fno-hosted.
See , for details of
freestanding and hosted environments.
-fopenaccEnable handling of OpenACC directives #pragma acc in C/C++ and
!$acc in Fortran.
When -fopenacc is specified, the
compiler generates accelerated code according to the OpenACC Application
Programming Interface v2.0 .
This option
implies -pthread, and thus is only supported on targets that
have support for -pthread.
-fopenacc-dim=geomSpecify default compute dimensions for parallel offload regions that do
not explicitly specify.
The geom value is a triple of
':'-separated sizes, in order 'gang', 'worker' and, 'vector'.
can be omitted, to use a target-specific default value.
-fopenmpEnable handling of OpenMP directives #pragma omp in C/C++ and
!$omp in Fortran.
When -fopenmp is specified, the
compiler generates parallel code according to the OpenMP Application
Program Interface v4.0 .
This option
implies -pthread, and thus is only supported on targets that
have support for -pthread. -fopenmp implies
-fopenmp-simd.
-fopenmp-simdEnable handling of OpenMP's SIMD directives with #pragma omp
in C/C++ and !$omp in Fortran. Other OpenMP directives
are ignored.
-fcilkplusEnable the usage of Cilk Plus language extension features for C/C++.
When the option -fcilkplus is specified, enable the usage of
the Cilk Plus Language extension features for C/C++.
The present
implementation follows ABI version 1.2.
This is an experimental
feature that is only partially complete, and whose interface may
change in future versions of GCC as the official specification
Currently, all features but _Cilk_for have been
implemented.
-fgnu-tmWhen the option -fgnu-tm is specified, the compiler
generates code for the Linux variant of Intel's current Transactional
Memory ABI specification document (Revision 1.1, May 6 2009).
an experimental feature whose interface may change in future versions
of GCC, as the official specification changes.
Please note that not
all architectures are supported for this feature.
For more information on GCC's support for transactional memory,
Note that the transactional memory feature is not supported with
non-call exceptions (-fnon-call-exceptions).
-fms-extensionsAccept some non-standard constructs used in Microsoft header files.
In C++ code, this allows member names in structures to be similar
to previous types declarations.
typedef int UOW;
struct ABC {
Some cases of unnamed fields in structures and unions are only
accepted with this option.
See , for details.
Note that this option is off for all targets but x86
targets using ms-abi.
-fplan9-extensionsAccept some non-standard constructs used in Plan 9 code.
This enables -fms-extensions, permits passing pointers to
structures with anonymous fields to functions that expect pointers to
elements of the type of the field, and permits referring to anonymous
fields declared using a typedef.
See , for details.
This is only
supported for C, not C++.
-trigraphsSupport ISO C trigraphs.
The -ansi option (and -std
options for strict ISO C conformance) implies -trigraphs.
-traditional-traditional-cppFormerly, these options caused GCC to attempt to emulate a pre-standard
C compiler.
They are now only supported with the -E switch.
The preprocessor continues to support a pre-standard mode.
See the GNU
CPP manual for details.
-fcond-mismatchAllow conditional expressions with mismatched types in the second and
third arguments.
The value of such an expression is void.
This option
is not supported for C++.
-flax-vector-conversionsAllow implicit conversions between vectors with differing numbers of
elements and/or incompatible element types.
This option should not be
used for new code.
-funsigned-charLet the type char be unsigned, like unsigned char.
Each kind of machine has a default for what char should
It is either like unsigned char by default or like
signed char by default.
Ideally, a portable program should always use signed char or
unsigned char when it depends on the signedness of an object.
But many programs have been written to use plain char and
expect it to be signed, or expect it to be unsigned, depending on the
machines they were written for.
This option, and its inverse, let you
make such a program work with the opposite default.
The type char is always a distinct type from each of
signed char or unsigned char, even though its behavior
is always just like one of those two.
-fsigned-charLet the type char be signed, like signed char.
Note that this is equivalent to -fno-unsigned-char, which is
the negative form of -funsigned-char.
Likewise, the option
-fno-signed-char is equivalent to -funsigned-char.
-fsigned-bitfields-funsigned-bitfields-fno-signed-bitfields-fno-unsigned-bitfieldsThese options control whether a bit-field is signed or unsigned, when the
declaration does not use either signed or unsigned.
default, such a bit-field is signed, because this is consistent: the
basic integer types such as int are signed types.
-fsso-struct=endiannessSet the default scalar storage order of structures and unions to the
specified endianness.
The accepted values are &big-endian& and
&little-endian&.
If the option is not passed, the compiler uses
the native endianness of the target.
This option is not supported for C++.
Warning: the -fsso-struct switch causes GCC to generate
code that is not binary compatible with code generated without it if the
specified endianness is not the native endianness of the target.【整理】C语言的各种版本:C89,AMD1,C99,C11 - 推酷
【整理】C语言的各种版本:C89,AMD1,C99,C11
之前就知道了有个C90和C99。
后来又在:
期间知道有C11。
现在去整理一下,关于C语言的版本方面的更详细的内容。
参考内容:
C语言版本历史
C语言主要有三个版本:
ANSI C==C89==C90
ANSI C standard
X3.159-1989
年批准通过;
后被批准为ISO标准:
偶尔被叫做:
GCC中指定此版本所用参数时,有三种写法:
此C90后来在1994年,1996年,先后发布过对应的勘误表;
AMD1==C94==C95
1995年,针对之前1900年发布的标准,发布了一个修订版;
添加了一个有向图(digraphs)和宏:
__STDC_VERSION__
此标准,常被叫做:
有时候被叫做:
GCC中指定此版本时所用参数:
年又发布了新标准:
常被叫做:
此C99标准未完成之前的草案,被叫做:
GCC中指定此版本时所用参数有两种写法:
此C99后来在2001年,2004年和2007年,先后发布过对应的勘误表;
年发布了新标准:
GCC中指定此版本时所用参数有两种写法:
此C11标准未完成之前的草案,被叫做:
关于GCC中对于C的扩展
对于GCC来说,对于上述各个版本的C语言,都有一定的扩展(extension)
如果用上面列出来的那些-std参数的话,则会禁止,不使用这些扩展的。
如果想要在GCC中使用C扩展的话,所用的参数都是gnuXX类型的,分别是:
C90使用GCC的C扩展:-std=gnu90
C99使用GCC的C扩展:-std=gnu99
C11使用GCC的C扩展:-std=gnu11
当前C language dialect默认所用的参数是:-std=gnu90
但是当以后,GCC对于C99和C11支持程度真正完善后,则可能会换成对应的:-std=gnu99或-std=gnu11
C语言库函数实现类型
ISO的C语言标准,定义了对于C语言的两种实现:
支持C语言的所有库函数
支持C语言的基本库函数( + 各自版本对应的实现)
基本库函数包括:
&float.h&,
&limits.h&,
&stdarg.h&,
&stddef.h&
AMD1对应的是:&iso646.h&
C99对应的是:&stdbool.h&,&stdint.h&
C11对应的是:&stdalign.h&,&stdnoreturn.h&
总结C语言的各种版本
语言的各种版本
X3.159-1989
标准通过时间
标准发布时间
使用此版本所用参数
使用此版本且带C扩展时所用参数
-std=gnu90
-std=gnu99
-std=gnu11
语言实现时所对应函数库
&limits.h&
&stdarg.h&
&stddef.h&
&iso646.h&
&stdbool.h&
&stdint.h&
&stdalign.h&
&stdnoreturn.h&
如此,就很清晰明了了。
已发表评论数()
已收藏到推刊!
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
没有分页内容
图片无法显示
视频无法显示
与原文不一致

我要回帖

更多关于 gcc.gnu.org 的文章

 

随机推荐