The following options control the dialect of C (or languages derived from C, such as C++, Objective-C and Objective-C++) that the compiler accepts:
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
typeof keywords, and
predefined macros such as
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 alternate keywords
__typeof__ continue to work despite
-ansi. 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
__vax__ are also available, with or
The -ansi option does not cause non-ISO programs to be rejected gratuitously. For that, -pedantic is required in addition to -ansi. See Warning Options.
__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't call for; this is to avoid interfering with any
programs that might use these names for other things.
Functions that would normally be built in but do not have semantics
defined by ISO C (such as
ffs) are not built-in
functions when -ansi is used. See Other built-in functions provided by GCC, for details of the functions
The compiler can accept several base standards, such as `c89' or
`c++98', and GNU dialects of those standards, such as
`gnu89' or `gnu++98'. By specifying a base standard, the
compiler will accept all programs following that standard and those
using GNU extensions that do not contradict it. For example,
`-std=c89' turns off certain features of GCC that are
incompatible with ISO C90, such as the
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, by specifying a GNU dialect of a
standard, all features the compiler support are enabled, even when
those features change the meaning of the base standard and some
strict-conforming programs may be rejected. The particular standard
is used by -pedantic to identify which features are GNU
extensions given that version of the standard. For example
`-std=gnu89 -pedantic' would warn about C++ style `//'
comments, while `-std=gnu99 -pedantic' would not.
A value for this option must be provided; possible values are
inlinefunctions when in C99 mode. See An Inline Function is As Fast As a Macro. This option is accepted and ignored by GCC versions 4.1.3 up to but not including 4.3. In GCC versions 4.3 and later it changes the behavior of GCC in C99 mode. Using this option is roughly equivalent to adding the
gnu_inlinefunction attribute to all inline functions (see Function Attributes).
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 was first supported in
GCC 4.3. This option is not supported in C89 or gnu89 mode.
The preprocessor macros
__GNUC_STDC_INLINE__ may be used to check which semantics are
in effect for
inline functions. See Common Predefined Macros.
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.
typeofas a keyword, so that code can use these words as identifiers. You can use the keywords
__typeof__instead. -ansi implies -fno-asm.
In C++, this switch only affects the
typeof keyword, since
inline are standard keywords. You may want to
use the -fno-gnu-keywords flag instead, which has the same
effect. In C99 mode (-std=c99 or -std=gnu99), this
switch only affects the
typeof keywords, since
inline is a standard keyword in ISO C99.
GCC normally generates special code to handle certain built-in functions
more efficiently; for instance, calls to
alloca may become single
instructions that adjust the stack directly, and calls to
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 is built in, and
known not to modify global memory.
With the -fno-builtin-function option only the built-in function function is disabled. function must not begin with `__builtin_'. If a function is named that is not built-in in this version of GCC, this option is ignored. There is no corresponding -fbuiltin-function option; 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))
mainhas a return type of
int. Examples are nearly everything except a kernel. This is equivalent to -fno-freestanding.
main. The most obvious example is an OS kernel. This is equivalent to -fno-hosted.
See Language Standards Supported by GCC, for details of
freestanding and hosted environments.
#pragma ompin C/C++ and
!$ompin Fortran. When -fopenmp is specified, the compiler generates parallel code according to the OpenMP Application Program Interface v2.5 http://www.openmp.org/. This option implies -pthread, and thus is only supported on targets that have support for -pthread.
Some cases of unnamed fields in structures and unions are only
accepted with this option. See Unnamed struct/union fields within structs/unions, for details.
The semantics of this option will change if "cc1", "cc1plus", and "cc1obj" are merged.
charbe unsigned, like
Each kind of machine has a default for what
be. 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
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.
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.
charbe signed, like
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.
unsigned. By default, such a bit-field is signed, because this is consistent: the basic integer types such as
intare signed types.