The following options control the dialect of C (or languages derived from C, such as C++ and Objective C) that the compiler accepts:
typeofkeywords, and predefined macros such as
vaxthat identify the type of system you are using. It also enables the undesirable and rarely used ANSI trigraph feature, and it disables recognition of C++ style `//' comments. The alternate keywords
__typeof__continue to work despite `-ansi'. You would not want to use them in an ANSI 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
__vax__are also available, with or without `-ansi'. The `-ansi' option does not cause non-ANSI programs to be rejected gratuitously. For that, `-pedantic' is required in addition to `-ansi'. See section Options to Request or Suppress Warnings. 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 ANSI standard doesn't call for; this is to avoid interfering with any programs that might use these names for other things. The functions
_exitare not builtin functions when `-ansi' is used.
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
inlineare standard keywords. You may want to use the `-fno-gnu-keywords' flag instead, as it also disables the other, C++-specific, extension keywords such as
strlen. GCC normally generates special code to handle certain builtin functions more efficiently; for instance, calls to
allocamay become single instructions that adjust the stack directly, and calls to
memcpymay 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. The `-ansi' option prevents
ffsfrom being builtin functions, since these functions do not have an ANSI standard meaning.
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'.
externdeclarations take effect globally even if they are written inside of a function definition. This includes implicit declarations of functions.
volatileare not recognized. (You can still use the alternative keywords such as
__inline__, and so on.)
unsigned charpromote to
registerare preserved by
longjmp. Ordinarily, GNU C follows ANSI C: automatic variables not declared
volatilemay be clobbered.
thisis permitted with `-traditional'. (The option `-fthis-is-variable' also has this effect.)
__STDC__is not defined when you use `-traditional', but
__GNUC__is (since the GNU extensions which
__GNUC__indicates are not affected by `-traditional'). If you need to write header files that work differently depending on whether `-traditional' is in use, by testing both of these predefined macros you can distinguish four situations: GNU C, traditional GNU C, other ANSI C compilers, and other old C compilers. The predefined macro
__STDC_VERSION__is also not defined when you use `-traditional'. See section `Standard Predefined Macros' in The C Preprocessor, for more discussion of these and other predefined macros.
charbe unsigned, like
unsigned char. Each kind of machine has a default for what
charshould be. It is either like
unsigned charby default or like
signed charby default. Ideally, a portable program should always use
unsigned charwhen it depends on the signedness of an object. But many programs have been written to use plain
charand 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
charis always a distinct type from each of
unsigned char, even though its behavior is always just like one of those two.
charbe 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'. You may wish to use `-fno-builtin' as well as `-traditional' if your program uses names that are normally GNU C builtin functions for other purposes of its own. You cannot use `-traditional' if you include any header files that rely on ANSI C features. Some vendors are starting to ship systems with ANSI C header files and you cannot use `-traditional' on such systems to compile files that include any system headers.
unsigned. By default, such a bitfield is signed, because this is consistent: the basic integer types such as
intare signed types. However, when `-traditional' is used, bitfields are all unsigned no matter what.
Go to the first, previous, next, last section, table of contents.