BBS水木清华站∶精华区
LANGUAGE OPTIONS
The following options control the dialect of C that the
compiler accepts:
-ansi Support all ANSI standard C programs.
This turns off certain features of GNU C that are
incompatible with ANSI C, such as the asm, inline
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 ANSI trigraph feature, and disallows
`$' as part of identifiers.
The alternate keywords __asm__, __extension__,
__inline__ and __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 compila-
tions done with `-ansi'. Alternate predefined
macros such as __unix__ and __vax__ are also avail-
able, 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'.
The preprocessor predefines a macro __STRICT_ANSI__
when you use the `-ansi' option. 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.
-fno-asm
Do not recognize asm, inline or typeof as a key-
word. These words may then be used as identifiers.
You can use __asm__, __inline__ and __typeof__ in-
stead. `-ansi' implies `-fno-asm'.
-fno-builtin
Don't recognize built-in functions that do not be-
gin with two leading underscores. Currently, the
functions affected include _exit, abort, abs, allo-
ca, cos, exit, fabs, labs, memcmp, memcpy, sin,
sqrt, strcmp, strcpy, and strlen.
The `-ansi' option prevents alloca and _exit from
being builtin functions.
-fno-strict-prototype
Treat a function declaration with no arguments,
such as `int foo ();', as C would treat it--as say-
ing nothing about the number of arguments or their
types (C++ only). Normally, such a declaration in
C++ means that the function foo takes no arguments.
-trigraphs
Support ANSI C trigraphs. The `-ansi' option im-
plies `-trigraphs'.
-traditional
Attempt to support some aspects of traditional C
compilers. For details, see the GNU C Manual; the
duplicate list here has been deleted so that we
won't get complaints when it is out of date.
But one note about C++ programs only (not C).
`-traditional' has one additional effect for C++:
assignment to this is permitted. This is the same
as the effect of `-fthis-is-variable'.
-traditional-cpp
Attempt to support some aspects of traditional C
preprocessors. This includes the items that
specifically mention the preprocessor above, but
none of the other effects of `-traditional'.
-fdollars-in-identifiers
Permit the use of `$' in identifiers (C++ only).
You can also use `-fno-dollars-in-identifiers' to
explicitly prohibit use of `$'. (GNU C++ allows
`$' by default on some target systems but not oth-
ers.)
-fenum-int-equiv
Permit implicit conversion of int to enumeration
types (C++ only). Normally GNU C++ allows conver-
sion of enum to int, but not the other way around.
-fexternal-templates
Produce smaller code for template declarations, by
generating only a single copy of each template
function where it is defined (C++ only). To use
this option successfully, you must also mark all
files that use templates with either `#pragma
implementation' (the definition) or `#pragma
interface' (declarations).
When your code is compiled with
`-fexternal-templates', all template instantiations
are external. You must arrange for all necessary
instantiations to appear in the implementation
file; you can do this with a typedef that refer-
ences each instantiation needed. Conversely, when
you compile using the default option
`-fno-external-templates', all template instantia-
tions are explicitly internal.
-fall-virtual
Treat all possible member functions as virtual, im-
plicitly. All member functions (except for con-
structor functions and new or delete member opera-
tors) are treated as virtual functions of the class
where they appear.
This does not mean that all calls to these member
functions will be made through the internal table
of virtual functions. Under some circumstances,
the compiler can determine that a call to a given
virtual function can be made directly; in these
cases the calls are direct in any case.
-fcond-mismatch
Allow conditional expressions with mismatched types
in the second and third arguments. The value of
such an expression is void.
-fthis-is-variable
Permit assignment to this (C++ only). The incorpo-
ration of user-defined free store management into
C++ has made assignment to `this' an anachronism.
Therefore, by default it is invalid to assign to
this within a class member function. However, for
backwards compatibility, you can make it valid with
`-fthis-is-variable'.
-funsigned-char
Let the type char be unsigned, like unsigned char.
Each kind of machine has a default for what char
should be. It is either like unsigned char by de-
fault 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 and unsigned char, even though its
behavior is always just like one of those two.
-fsigned-char
Let 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, `-fno-signed-char' is
equivalent to `-funsigned-char'.
-fsigned-bitfields
-funsigned-bitfields
-fno-signed-bitfields
-fno-unsigned-bitfields
These options control whether a bitfield is signed
or unsigned, when declared with no explicit
`signed' or `unsigned' qualifier. By default, such
a bitfield is signed, because this is consistent:
the basic integer types such as int are signed
types.
However, when you specify `-traditional', bitfields
are all unsigned no matter what.
-fwritable-strings
Store string constants in the writable data segment
and don't uniquize them. This is for compatibility
with old programs which assume they can write into
string constants. `-traditional' also has this ef-
fect.
Writing into string constants is a very bad idea;
"constants" should be constant.
BBS水木清华站∶精华区