⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 invoke.texi

📁 GCC
💻 TEXI
📖 第 1 页 / 共 5 页
字号:

GCC normally generates special code to handle certain built-in functions
more efficiently; for instance, calls to @code{alloca} may become single
instructions that adjust the stack directly, and calls to @code{memcpy}
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 C++, @option{-fno-builtin} is always in effect.  The @option{-fbuiltin}
option has no effect.  Therefore, in C++, the only way to get the
optimization benefits of built-in functions is to call the function
using the @samp{__builtin_} prefix.  The GNU C++ Standard Library uses
built-in functions to implement many functions (like
@code{std::strchr}), so that you automatically get efficient code.

@item -fhosted
@opindex fhosted
@cindex hosted environment

Assert that compilation takes place in a hosted environment.  This implies
@option{-fbuiltin}.  A hosted environment is one in which the
entire standard library is available, and in which @code{main} has a return
type of @code{int}.  Examples are nearly everything except a kernel.
This is equivalent to @option{-fno-freestanding}.

@item -ffreestanding
@opindex ffreestanding
@cindex hosted environment

Assert that compilation takes place in a freestanding environment.  This
implies @option{-fno-builtin}.  A freestanding environment
is one in which the standard library may not exist, and program startup may
not necessarily be at @code{main}.  The most obvious example is an OS kernel.
This is equivalent to @option{-fno-hosted}.

@xref{Standards,,Language Standards Supported by GCC}, for details of
freestanding and hosted environments.

@item -trigraphs
@opindex trigraphs
Support ISO C trigraphs.  The @option{-ansi} option (and @option{-std}
options for strict ISO C conformance) implies @option{-trigraphs}.

@cindex traditional C language
@cindex C language, traditional
@item -traditional
@opindex traditional
Attempt to support some aspects of traditional C compilers.
Specifically:

@itemize @bullet
@item
All @code{extern} declarations take effect globally even if they
are written inside of a function definition.  This includes implicit
declarations of functions.

@item
The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}
and @code{volatile} are not recognized.  (You can still use the
alternative keywords such as @code{__typeof__}, @code{__inline__}, and
so on.)

@item
Comparisons between pointers and integers are always allowed.

@item
Integer types @code{unsigned short} and @code{unsigned char} promote
to @code{unsigned int}.

@item
Out-of-range floating point literals are not an error.

@item
Certain constructs which ISO regards as a single invalid preprocessing
number, such as @samp{0xe-0xd}, are treated as expressions instead.

@item
String ``constants'' are not necessarily constant; they are stored in
writable space, and identical looking constants are allocated
separately.  (This is the same as the effect of
@option{-fwritable-strings}.)

@cindex @code{longjmp} and automatic variables
@item
All automatic variables not declared @code{register} are preserved by
@code{longjmp}.  Ordinarily, GNU C follows ISO C: automatic variables
not declared @code{volatile} may be clobbered.

@item
@cindex @samp{\x}
@cindex @samp{\a}
@cindex escape sequences, traditional
The character escape sequences @samp{\x} and @samp{\a} evaluate as the
literal characters @samp{x} and @samp{a} respectively.  Without
@w{@option{-traditional}}, @samp{\x} is a prefix for the hexadecimal
representation of a character, and @samp{\a} produces a bell.
@end itemize

You may wish to use @option{-fno-builtin} as well as @option{-traditional}
if your program uses names that are normally GNU C built-in functions for
other purposes of its own.

You cannot use @option{-traditional} if you include any header files that
rely on ISO C features.  Some vendors are starting to ship systems with
ISO C header files and you cannot use @option{-traditional} on such
systems to compile files that include any system headers.

The @option{-traditional} option also enables @option{-traditional-cpp},
which is described next.

@item -traditional-cpp
@opindex traditional-cpp
Attempt to support some aspects of traditional C preprocessors.
Specifically:

@itemize @bullet
@item
Comments convert to nothing at all, rather than to a space.  This allows
traditional token concatenation.

@item
In a preprocessing directive, the @samp{#} symbol must appear as the first
character of a line.

@item
Macro arguments are recognized within string constants in a macro
definition (and their values are stringified, though without additional
quote marks, when they appear in such a context).  The preprocessor
always considers a string constant to end at a newline.

@item
@cindex detecting @w{@option{-traditional}}
The predefined macro @code{__STDC__} is not defined when you use
@option{-traditional}, but @code{__GNUC__} is (since the GNU extensions
which @code{__GNUC__} indicates are not affected by
@option{-traditional}).  If you need to write header files that work
differently depending on whether @option{-traditional} is in use, by
testing both of these predefined macros you can distinguish four
situations: GNU C, traditional GNU C, other ISO C compilers, and other
old C compilers.  The predefined macro @code{__STDC_VERSION__} is also
not defined when you use @option{-traditional}.  @xref{Standard
Predefined,,Standard Predefined Macros,cpp.info,The C Preprocessor},
for more discussion of these and other predefined macros.

@item
@cindex string constants vs newline
@cindex newline vs string constants
The preprocessor considers a string constant to end at a newline (unless
the newline is escaped with @samp{\}).  (Without @w{@option{-traditional}},
string constants can contain the newline character as typed.)
@end itemize

@item -fcond-mismatch
@opindex fcond-mismatch
Allow conditional expressions with mismatched types in the second and
third arguments.  The value of such an expression is void.  This option
is not supported for C++.

@item -funsigned-char
@opindex funsigned-char
Let the type @code{char} be unsigned, like @code{unsigned char}.

Each kind of machine has a default for what @code{char} should
be.  It is either like @code{unsigned char} by default or like
@code{signed char} by default.

Ideally, a portable program should always use @code{signed char} or
@code{unsigned char} when it depends on the signedness of an object.
But many programs have been written to use plain @code{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 @code{char} is always a distinct type from each of
@code{signed char} or @code{unsigned char}, even though its behavior
is always just like one of those two.

@item -fsigned-char
@opindex fsigned-char
Let the type @code{char} be signed, like @code{signed char}.

Note that this is equivalent to @option{-fno-unsigned-char}, which is
the negative form of @option{-funsigned-char}.  Likewise, the option
@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.

@item -fsigned-bitfields
@itemx -funsigned-bitfields
@itemx -fno-signed-bitfields
@itemx -fno-unsigned-bitfields
@opindex fsigned-bitfields
@opindex funsigned-bitfields
@opindex fno-signed-bitfields
@opindex fno-unsigned-bitfields
These options control whether a bit-field is signed or unsigned, when the
declaration does not use either @code{signed} or @code{unsigned}.  By
default, such a bit-field is signed, because this is consistent: the
basic integer types such as @code{int} are signed types.

However, when @option{-traditional} is used, bit-fields are all unsigned
no matter what.

@item -fwritable-strings
@opindex 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.  The option @option{-traditional} also has
this effect.

Writing into string constants is a very bad idea; ``constants'' should
be constant.

@item -fallow-single-precision
@opindex fallow-single-precision
Do not promote single precision math operations to double precision,
even when compiling with @option{-traditional}.

Traditional K&R C promotes all floating point operations to double
precision, regardless of the sizes of the operands.   On the
architecture for which you are compiling, single precision may be faster
than double precision.   If you must use @option{-traditional}, but want
to use single precision operations when the operands are single
precision, use this option.   This option has no effect when compiling
with ISO or GNU C conventions (the default).

@item -fshort-wchar
@opindex fshort-wchar
Override the underlying type for @samp{wchar_t} to be @samp{short
unsigned int} instead of the default for the target.  This option is
useful for building programs to run under WINE.
@end table

@node C++ Dialect Options
@section Options Controlling C++ Dialect

@cindex compiler options, C++
@cindex C++ options, command line
@cindex options, C++
This section describes the command-line options that are only meaningful
for C++ programs; but you can also use most of the GNU compiler options
regardless of what language your program is in.  For example, you
might compile a file @code{firstClass.C} like this:

@example
g++ -g -frepo -O -c firstClass.C
@end example

@noindent
In this example, only @option{-frepo} is an option meant
only for C++ programs; you can use the other options with any
language supported by GCC.

Here is a list of options that are @emph{only} for compiling C++ programs:

@table @gcctabopt
@item -fno-access-control
@opindex fno-access-control
Turn off all access checking.  This switch is mainly useful for working
around bugs in the access control code.

@item -fcheck-new
@opindex fcheck-new
Check that the pointer returned by @code{operator new} is non-null
before attempting to modify the storage allocated.  The current Working
Paper requires that @code{operator new} never return a null pointer, so
this check is normally unnecessary.

An alternative to using this option is to specify that your
@code{operator new} does not throw any exceptions; if you declare it
@samp{throw()}, g++ will check the return value.  See also @samp{new
(nothrow)}.

@item -fconserve-space
@opindex fconserve-space
Put uninitialized or runtime-initialized global variables into the
common segment, as C does.  This saves space in the executable at the
cost of not diagnosing duplicate definitions.  If you compile with this
flag and your program mysteriously crashes after @code{main()} has
completed, you may have an object that is being destroyed twice because
two definitions were merged.

This option is no longer useful on most targets, now that support has
been added for putting variables into BSS without making them common.

@item -fno-const-strings
@opindex fno-const-strings
Give string constants type @code{char *} instead of type @code{const
char *}.  By default, G++ uses type @code{const char *} as required by
the standard.  Even if you use @option{-fno-const-strings}, you cannot
actually modify the value of a string constant, unless you also use
@option{-fwritable-strings}.

This option might be removed in a future release of G++.  For maximum
portability, you should structure your code so that it works with
string constants that have type @code{const char *}.

@item -fdollars-in-identifiers
@opindex fdollars-in-identifiers
Accept @samp{$} in identifiers.  You can also explicitly prohibit use of
@samp{$} with the option @option{-fno-dollars-in-identifiers}.  (GNU C allows
@samp{$} by default on most target systems, but there are a few exceptions.)
Traditional C allowed the character @samp{$} to form part of
identifiers.  However, ISO C and C++ forbid @samp{$} in identifiers.

@item -fno-elide-constructors
@opindex fno-elide-constructors
The C++ standard allows an implementation to omit creating a temporary
which is only used to initialize another object of the same type.
Specifying this option disables that optimization, and forces g++ to
call the copy constructor in all cases.

@item -fno-enforce-eh-specs
@opindex fno-enforce-eh-specs
Don't check for violation of exception specifications at runtime.  This
option violates the C++ standard, but may be useful for reducing code
size in production builds, much like defining @samp{NDEBUG}.  The compiler
will still optimize based on the exception specifications.

@item -fexternal-templates
@opindex fexternal-templates
Cause template instantiations to obey @samp{#pragma interface} and
@samp{implementation}; template instances are emitted or not according
to the location of the template definition.  @xref{Template
Instantiation}, for more information.

This option is deprecated.

@item -falt-external-templates
@opindex falt-external-templates
Similar to @option{-fexternal-templates}, but template instances are emitted or
not according to the place where they are first instantiated.
@xref{Template Instantiation}, for more information.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -