It is basically 'the intersection of C and C99'. It can't quite be that because so few compilers are 100% C99-compliant. By compiling with MSVC in C mode, we are able to get the features of C99 that are most useful without dropping support for that compiler. One of these is 'mixed declarations and code'. Another is 'for loop initial.
Next: C++ Dialect Options, Previous: Invoking G++, Up: Invoking GCC [Contents][Index]
3.4 Options Controlling C Dialect
The following options control the dialect of C (or languages derivedfrom C, such as C++, Objective-C and Objective-C++) that the compileraccepts:
In C mode, this is equivalent to -std=c90. In C++ mode, it isequivalent to -std=c++98.
This turns off certain features of GCC that are incompatible with ISOC90 (when compiling C code), or of standard C++ (when compiling C++ code),such as the
typeof keywords, andpredefined macros such as
vax that identify thetype of system you are using. It also enables the undesirable andrarely used ISO trigraph feature. For the C compiler,it disables recognition of C++ style ‘//’ comments as well asthe
The alternate keywords
__typeof__ continue to work despite-ansi. You would not want to use them in an ISO C program, ofcourse, but it is useful to put them in header files that might be includedin compilations done with -ansi. Alternate predefined macrossuch as
__vax__ are also available, with orwithout -ansi.
The -ansi option does not cause non-ISO programs to berejected gratuitously. For that, -Wpedantic is required inaddition to -ansi. See Warning Options.
__STRICT_ANSI__ is predefined when the -ansioption is used. Some header files may notice this macro and refrainfrom declaring certain functions or defining certain macros that theISO standard doesn’t call for; this is to avoid interfering with anyprograms that might use these names for other things.
Functions that are normally built in but do not have semanticsdefined by ISO C (such as
ffs) are not built-infunctions when -ansi is used. See Otherbuilt-in functions provided by GCC, for details of the functionsaffected.
Determine the language standard. See Language StandardsSupported by GCC, for details of these standard versions. This optionis 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, thecompiler accepts all programs following that standard plus thoseusing GNU extensions that do not contradict it. For example,-std=c90 turns off certain features of GCC that areincompatible with ISO C90, such as the
typeofkeywords, but not other GNU extensions that do not have a meaning inISO C90, such as omitting the middle term of a
?:expression. On the other hand, when a GNU dialect of a standard isspecified, all features supported by the compiler are enabled, even whenthose features change the meaning of the base standard. As a result, somestrict-conforming programs may be rejected. The particular standardis used by -Wpedantic to identify which features are GNUextensions 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 option must be provided; possible values are
Support all ISO C90 programs (certain GNU extensions that conflictwith ISO C90 are disabled). Same as -ansi for C code.
ISO C90 as modified in amendment 1.
ISO C99. This standard is substantially completely supported, modulobugs and floating-point issues(mainly but not entirely relating to optional C99 features fromAnnexes F and G). Seehttp://gcc.gnu.org/c99status.html for more information. Thenames ‘c9x’ and ‘iso9899:199x’ are deprecated.
ISO C11, the 2011 revision of the ISO C standard. This standard issubstantially completely supported, modulo bugs, floating-point issues(mainly but not entirely relating to optional C11 features fromAnnexes F and G) and the optional Annexes K (Bounds-checkinginterfaces) and L (Analyzability). The name ‘c1x’ is deprecated.
ISO C17, the 2017 revision of the ISO C standard(published in 2018). This standard issame as C11 except for corrections of defects (all of which are alsoapplied with -std=c11) and a new value of
__STDC_VERSION__, and so is supported to the same extent as C11.
The next version of the ISO C standard, still under development. Thesupport for this version is experimental and incomplete.
GNU dialect of ISO C90 (including some C99 features).
C99 Mode Dev C 2b 2b 3
GNU dialect of ISO C99. The name ‘gnu9x’ is deprecated.
GNU dialect of ISO C11.The name ‘gnu1x’ is deprecated.
GNU dialect of ISO C17. This is the default for C code.
The next version of the ISO C standard, still under development, plusGNU extensions. The support for this version is experimental andincomplete.
The 1998 ISO C++ standard plus the 2003 technical corrigendum and someadditional defect reports. Same as -ansi for C++ code.
GNU dialect of -std=c++98.
The 2011 ISO C++ standard plus amendments.The name ‘c++0x’ is deprecated.
GNU dialect of -std=c++11.The name ‘gnu++0x’ is deprecated.
The 2014 ISO C++ standard plus amendments.The name ‘c++1y’ is deprecated.
GNU dialect of -std=c++14.The name ‘gnu++1y’ is deprecated.
The 2017 ISO C++ standard plus amendments.The name ‘c++1z’ is deprecated.
GNU dialect of -std=c++17.This is the default for C++ code.The name ‘gnu++1z’ is deprecated.
The 2020 ISO C++ standard plus amendments.Support is experimental, and could change in incompatible ways infuture releases.The name ‘c++2a’ is deprecated.
GNU dialect of -std=c++20.Support is experimental, and could change in incompatible ways infuture releases.The name ‘gnu++2a’ is deprecated.
The option -fgnu89-inline tells GCC to use the traditionalGNU semantics for
inline functions when in C99 mode.See An Inline Function is As Fast As a Macro.Using this option is roughly equivalent to adding the
gnu_inline function attribute to all inline functions(see Function Attributes).
The option -fno-gnu89-inline explicitly tells GCC to use theC99 semantics for
inline when in C99 or gnu99 mode (i.e., itspecifies the default behavior).This option is not supported in -std=c90 or-std=gnu90 mode.
The preprocessor macros
__GNUC_STDC_INLINE__ may be used to check which semantics arein effect for
inline functions. See Common PredefinedMacros in The C Preprocessor.
ISO/IEC TS 18661-3 defines new permissible values for
FLT_EVAL_METHOD that indicate that operations and constants witha semantic type that is an interchange or extended format should beevaluated to the precision and range of that type. These new values area superset of those permitted under C99/C11, which does not specify themeaning of other positive values of
FLT_EVAL_METHOD. As such, codeconforming to C11 may not have been written expecting the possibility ofthe new values.
-fpermitted-flt-eval-methods specifies whether the compilershould allow only the values of
FLT_EVAL_METHOD specified in C99/C11,or the extended set of values specified in ISO/IEC TS 18661-3.
style is either
ts-18661-3 as appropriate.
The default when in a standards compliant mode (-std=c11 or similar)is -fpermitted-flt-eval-methods=c11. The default when in a GNUdialect (-std=gnu11 or similar) is-fpermitted-flt-eval-methods=ts-18661-3.
Output to the given filename prototyped declarations for all functionsdeclared and/or defined in a translation unit, including those in headerfiles. This option is silently ignored in any language other than C.
Besides declarations, the file indicates, in comments, the origin ofeach declaration (source file and line), whether the declaration wasimplicit, prototyped or unprototyped (‘I’, ‘N’ for new or‘O’ for old, respectively, in the first character after the linenumber and the colon), and whether it came from a declaration or adefinition (‘C’ or ‘F’, respectively, in the followingcharacter). In the case of function definitions, a K&R-style list ofarguments followed by their declarations is also provided, insidecomments, after the declaration.
Accept variadic functions without named parameters.
Although it is possible to define such a function, this is not veryuseful as it is not possible to read the arguments. This is onlysupported for C as this construct is allowed by C++.
Do not recognize
typeof as akeyword, so that code can use these words as identifiers. You can usethe keywords
__typeof__instead. -ansi implies -fno-asm.
In C++, this switch only affects the
typeof keyword, since
inline are standard keywords. You may want touse the -fno-gnu-keywords flag instead, which has the sameeffect. In C99 mode (-std=c99 or -std=gnu99), thisswitch only affects the
typeof keywords, since
inline is a standard keyword in ISO C99.
Don’t recognize built-in functions that do not begin with‘__builtin_’ as prefix. See Other built-infunctions provided by GCC, 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 theydo not have an ISO standard meaning.
GCC normally generates special code to handle certain built-in functionsmore efficiently; for instance, calls to
alloca may become singleinstructions which adjust the stack directly, and calls to
memcpymay become inline copy loops. The resulting code is often both smallerand faster, but since the function calls no longer appear as such, youcannot set a breakpoint on those calls, nor can you change the behaviorof the functions by linking with a different library. In addition,when a function is recognized as a built-in function, GCC may useinformation about that function to warn about problems with calls tothat function, or to generate more efficient code, even if theresulting code still contains calls to that function. For example,warnings are given with -Wformat for bad calls to
printf is built in and
strlen isknown not to modify global memory.
With the -fno-builtin-function optiononly the built-in function function isdisabled. function must not begin with ‘__builtin_’. If afunction is named that is not built-in in this version of GCC, thisoption is ignored. There is no corresponding-fbuiltin-function option; if you wish to enablebuilt-in functions selectively when using -fno-builtin or-ffreestanding, you may define macros such as:
Enable parsing of function definitions marked with
__GIMPLE.This is an experimental feature that allows unit testing of GIMPLEpasses.
Assert that compilation targets a hosted environment. This implies-fbuiltin. A hosted environment is one in which theentire standard library is available, and in which
main has a returntype of
int. Examples are nearly everything except a kernel.This is equivalent to -fno-freestanding.
Assert that compilation targets a freestanding environment. Thisimplies -fno-builtin. A freestanding environmentis one in which the standard library may not exist, and program startup maynot necessarily be at
main. The most obvious example is an OS kernel.This is equivalent to -fno-hosted.
See Language Standards Supported by GCC, for details offreestanding and hosted environments.
Enable handling of OpenACC directives
#pragma acc in C/C++ and
!$acc in Fortran. When -fopenacc is specified, thecompiler generates accelerated code according to the OpenACC ApplicationProgramming Interface v2.6 https://www.openacc.org. This optionimplies -pthread, and thus is only supported on targets thathave support for -pthread.
Specify default compute dimensions for parallel offload regions that donot explicitly specify. The geom value is a triple of’:’-separated sizes, in order ’gang’, ’worker’ and, ’vector’. A sizecan be omitted, to use a target-specific default value.
Specify mode of OpenACC ‘kernels’ constructs handling.With -fopenacc-kernels=decompose, OpenACC ‘kernels’constructs are decomposed into parts, a sequence of computeconstructs, each then handled individually.This is work in progress.With -fopenacc-kernels=parloops, OpenACC ‘kernels’ constructsare handled by the ‘parloops’ pass, en bloc.This is the current default.
Enable handling of OpenMP directives
#pragma omp in C/C++ and
!$omp in Fortran. When -fopenmp is specified, thecompiler generates parallel code according to the OpenMP ApplicationProgram Interface v4.5 https://www.openmp.org. This optionimplies -pthread, and thus is only supported on targets thathave support for -pthread. -fopenmp implies-fopenmp-simd.
Enable handling of OpenMP’s SIMD directives with
#pragma ompin C/C++ and
!$omp in Fortran. Other OpenMP directivesare ignored.
When the option -fgnu-tm is specified, the compilergenerates code for the Linux variant of Intel’s current TransactionalMemory ABI specification document (Revision 1.1, May 6 2009). This isan experimental feature whose interface may change in future versionsof GCC, as the official specification changes. Please note that notall architectures are supported for this feature.
For more information on GCC’s support for transactional memory,See The GNU Transactional Memory Library in GNUTransactional Memory Library.
Note that the transactional memory feature is not supported withnon-call exceptions (-fnon-call-exceptions).
Accept some non-standard constructs used in Microsoft header files.
In C++ code, this allows member names in structures to be similarto previous types declarations.
Some cases of unnamed fields in structures and unions are onlyaccepted with this option. See Unnamed struct/unionfields within structs/unions, for details.
Note that this option is off for all targets except for x86targets using ms-abi.
Accept some non-standard constructs used in Plan 9 code.
This enables -fms-extensions, permits passing pointers tostructures with anonymous fields to functions that expect pointers toelements of the type of the field, and permits referring to anonymousfields declared using a typedef. See Unnamedstruct/union fields within structs/unions, for details. This is onlysupported for C, not C++.
Allow conditional expressions with mismatched types in the second andthird arguments. The value of such an expression is void. This optionis not supported for C++.
Allow implicit conversions between vectors with differing numbers ofelements and/or incompatible element types. This option should not beused for new code.
Let the type
char be unsigned, like
Each kind of machine has a default for what
char shouldbe. 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 andexpect it to be signed, or expect it to be unsigned, depending on themachines they were written for. This option, and its inverse, let youmake such a program work with the opposite default.
char is always a distinct type from each of
signed char or
unsigned char, even though its behavioris always just like one of those two.
Let the type
char be signed, like
Note that this is equivalent to -fno-unsigned-char, which isthe negative form of -funsigned-char. Likewise, the option-fno-signed-char is equivalent to -funsigned-char.
These options control whether a bit-field is signed or unsigned, when thedeclaration does not use either
unsigned. Bydefault, such a bit-field is signed, because this is consistent: thebasic integer types such as
int are signed types.
Set the default scalar storage order of structures and unions to thespecified endianness. The accepted values are ‘big-endian’,‘little-endian’ and ‘native’ for the native endianness ofthe target (the default). This option is not supported for C++.
Warning: the -fsso-struct switch causes GCC to generatecode that is not binary compatible with code generated without it if thespecified endianness is not the native endianness of the target.
Next: C++ Dialect Options, Previous: Invoking G++, Up: Invoking GCC [Contents][Index]