3.4 Options Controlling C Dialect
The following options control the dialect of C (or languages derivedfrom C, such as C++ and Objective-C) that the compiler accepts:
-
In C mode, support all ISO C90 programs. In C++ mode,remove GNU extensions that conflict with ISO C++.
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
asm
andtypeof
keywords, andpredefined macros such asunix
andvax
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 astheinline
keyword.The alternate keywords
__asm__
,__extension__
,__inline__
and__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__unix__
and__vax__
are also available, with orwithout -ansi.The -ansi option does not cause non-ISO programs to berejected gratuitously. For that, -pedantic is required inaddition to -ansi. See Warning Options.
The macro
__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 which would normally be built in but do not have semanticsdefined by ISO C (such as
alloca
andffs
) are not built-infunctions with -ansi is used. See Other built-in functions provided by GCC, for details of the functionsaffected.
-
Determine the language standard. This option is currently onlysupported when compiling C or C++. A value for this option must beprovided; possible values are
-
`
c89'
`
iso9899:1990'
-
ISO C90 (same as
-ansi).
`
iso9899:199409'
-
ISO C90 as modified in amendment 1.
`
c99'
`
c9x'
`
iso9899:1999'
`
iso9899:199x'
-
ISO C99. Note that this standard is not yet fully supported; see
http://gcc.gnu.org/gcc-3.4/c99status.html for more information. Thenames `
c9x' and `
iso9899:199x' are deprecated.
`
gnu89'
-
Default, ISO C90 plus GNU extensions (including some C99 features).
`
gnu99'
`
gnu9x'
-
ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC,this will become the default. The name `
gnu9x' is deprecated.
`
c++98'
-
The 1998 ISO C++ standard plus amendments.
`
gnu++98'
- The same as -std=c++98 plus GNU extensions. This is thedefault for C++ code.
Even when this option is not specified, you can still use some of thefeatures of newer standards in so far as they do not conflict withprevious C standards. For example, you may use
__restrict__
evenwhen -std=c99 is not specified.The -std options specifying some version of ISO C have the sameeffects as -ansi, except that features that were not in ISO C90but are in the specified version (for example, `//' comments andthe
inline
keyword in ISO C99) are not disabled.See Language Standards Supported by GCC, for details ofthese standard versions.
-
ISO C90 (same as
-ansi).
-
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.
-
Do not recognize
asm
,inline
ortypeof
as akeyword, so that code can use these words as identifiers. You can usethe keywords__asm__
,__inline__
and__typeof__
instead. -ansi implies -fno-asm.In C++, this switch only affects the
typeof
keyword, sinceasm
andinline
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 theasm
andtypeof
keywords, sinceinline
is a standard keyword in ISO C99.
-
Don't recognize built-in functions that do not begin with`
__builtin_' as prefix. See
Other built-in functions 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 that adjust the stack directly, and calls tomemcpy
may 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.With the -fno-builtin-function optiononly the built-in function function isdisabled. function must not begin with `__builtin_'. If afunction is named this 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:
#define abs(n) __builtin_abs ((n)) #define strcpy(d, s) __builtin_strcpy ((d), (s))
-
Assert that compilation takes place in 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 ofint
. Examples are nearly everything except a kernel. This is equivalent to -fno-freestanding.
-
Assert that compilation takes place in 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.
-
Accept some non-standard constructs used in Microsoft header files.
-
Support ISO C trigraphs. The
-ansi option (and
-stdoptions for strict ISO C conformance) implies
-trigraphs.
-
Performs a compilation in two passes: preprocessing and compiling. Thisoption allows a user supplied "cc1", "cc1plus", or "cc1obj" via the
-B option. The user supplied compilation step can then add inan additional preprocessing step after normal preprocessing but beforecompiling. The default is to use the integrated cpp (internal cpp)
The semantics of this option will change if "cc1", "cc1plus", and"cc1obj" are merged.
-
Formerly, these options caused GCC to attempt to emulate a pre-standardC compiler. They are now only supported with the
-E switch. The preprocessor continues to support a pre-standard mode. See the GNUCPP manual for details.
-
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++.
-
Let the type
char
be unsigned, likeunsigned char
.Each kind of machine has a default for what
char
shouldbe. It is either likeunsigned char
by default or likesigned char
by default.Ideally, a portable program should always use
signed char
orunsigned char
when it depends on the signedness of an object. But many programs have been written to use plainchar
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.The type
char
is always a distinct type from each ofsigned char
orunsigned char
, even though its behavioris always just like one of those two.
-
Let the type
char
be signed, likesigned char
.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
signed
orunsigned
. Bydefault, such a bit-field is signed, because this is consistent: thebasic integer types such asint
are signed types.
-
Store string constants in the writable data segment and don't uniquizethem. This is for compatibility with old programs which assume they canwrite into string constants.
Writing into string constants is a very bad idea; “constants” shouldbe constant.
This option is deprecated.
-ansi
-std=
-aux-info
filename
-fno-asm
-fno-builtin
-fno-builtin-
function
-fhosted
-ffreestanding
-fms-extensions
-trigraphs
-no-integrated-cpp
-traditional
-traditional-cpp
-fcond-mismatch
-funsigned-char
-fsigned-char
-fsigned-bitfields
-funsigned-bitfields
-fno-signed-bitfields
-fno-unsigned-bitfields
-fwritable-strings