📄 c---dialect-options.html
字号:
<html lang="en"><head><title>Using the GNU Compiler Collection (GCC)</title><meta http-equiv="Content-Type" content="text/html"><meta name="description" content="Using the GNU Compiler Collection (GCC)"><meta name="generator" content="makeinfo 4.6"><!--Copyright © 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. <p>Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being "GNU General Public License" and "FundingFree Software", the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below). A copy of the license isincluded in the section entitled "GNU Free Documentation License". <p>(a) The FSF's Front-Cover Text is: <p>A GNU Manual <p>(b) The FSF's Back-Cover Text is: <p>You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.--><meta http-equiv="Content-Style-Type" content="text/css"><style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller }--></style></head><body><div class="node"><p>Node: <a name="C++%20Dialect%20Options">C++ Dialect Options</a>,Next: <a rel="next" accesskey="n" href="Objective-C-Dialect-Options.html#Objective-C%20Dialect%20Options">Objective-C Dialect Options</a>,Previous: <a rel="previous" accesskey="p" href="C-Dialect-Options.html#C%20Dialect%20Options">C Dialect Options</a>,Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking%20GCC">Invoking GCC</a><hr><br></div><h3 class="section">Options Controlling C++ Dialect</h3><p>This section describes the command-line options that are only meaningfulfor C++ programs; but you can also use most of the GNU compiler optionsregardless of what language your program is in. For example, youmight compile a file <code>firstClass.C</code> like this:<pre class="smallexample"> g++ -g -frepo -O -c firstClass.C </pre><p>In this example, only <code>-frepo</code> is an option meantonly for C++ programs; you can use the other options with anylanguage supported by GCC. <p>Here is a list of options that are <em>only</em> for compiling C++ programs: <dl> <br><dt><code>-fabi-version=</code><var>n</var><code></code> <dd>Use version <var>n</var> of the C++ ABI. Version 2 is the version of theC++ ABI that first appeared in G++ 3.4. Version 1 is the version ofthe C++ ABI that first appeared in G++ 3.2. Version 0 will always bethe version that conforms most closely to the C++ ABI specification. Therefore, the ABI obtained using version 0 will change as ABI bugsare fixed. <p>The default is version 2. <br><dt><code>-fno-access-control</code> <dd>Turn off all access checking. This switch is mainly useful for workingaround bugs in the access control code. <br><dt><code>-fcheck-new</code> <dd>Check that the pointer returned by <code>operator new</code> is non-nullbefore attempting to modify the storage allocated. This check isnormally unnecessary because the C++ standard specifies that<code>operator new</code> will only return <code>0</code> if it is declared<code>throw()</code>, in which case the compiler will always check thereturn value even without this option. In all other cases, when<code>operator new</code> has a non-empty exception specification, memoryexhaustion is signalled by throwing <code>std::bad_alloc</code>. See also<code>new (nothrow)</code>. <br><dt><code>-fconserve-space</code> <dd>Put uninitialized or runtime-initialized global variables into thecommon segment, as C does. This saves space in the executable at thecost of not diagnosing duplicate definitions. If you compile with thisflag and your program mysteriously crashes after <code>main()</code> hascompleted, you may have an object that is being destroyed twice becausetwo definitions were merged. <p>This option is no longer useful on most targets, now that support hasbeen added for putting variables into BSS without making them common. <br><dt><code>-fno-const-strings</code> <dd>Give string constants type <code>char *</code> instead of type <code>constchar *</code>. By default, G++ uses type <code>const char *</code> as required bythe standard. Even if you use <code>-fno-const-strings</code>, you cannotactually modify the value of a string constant. <p>This option might be removed in a future release of G++. For maximumportability, you should structure your code so that it works withstring constants that have type <code>const char *</code>. <br><dt><code>-fno-elide-constructors</code> <dd>The C++ standard allows an implementation to omit creating a temporarywhich is only used to initialize another object of the same type. Specifying this option disables that optimization, and forces G++ tocall the copy constructor in all cases. <br><dt><code>-fno-enforce-eh-specs</code> <dd>Don't check for violation of exception specifications at runtime. Thisoption violates the C++ standard, but may be useful for reducing codesize in production builds, much like defining <code>NDEBUG</code>. The compilerwill still optimize based on the exception specifications. <br><dt><code>-ffor-scope</code> <dd><dt><code>-fno-for-scope</code> <dd>If <code>-ffor-scope</code> is specified, the scope of variables declared ina <i>for-init-statement</i> is limited to the <code>for</code> loop itself,as specified by the C++ standard. If <code>-fno-for-scope</code> is specified, the scope of variables declared ina <i>for-init-statement</i> extends to the end of the enclosing scope,as was the case in old versions of G++, and other (traditional)implementations of C++. <p>The default if neither flag is given to follow the standard,but to allow and give a warning for old-style code that wouldotherwise be invalid, or have different behavior. <br><dt><code>-fno-gnu-keywords</code> <dd>Do not recognize <code>typeof</code> as a keyword, so that code can use thisword as an identifier. You can use the keyword <code>__typeof__</code> instead. <code>-ansi</code> implies <code>-fno-gnu-keywords</code>. <br><dt><code>-fno-implicit-templates</code> <dd>Never emit code for non-inline templates which are instantiatedimplicitly (i.e. by use); only emit code for explicit instantiations. See <a href="Template-Instantiation.html#Template%20Instantiation">Template Instantiation</a>, for more information. <br><dt><code>-fno-implicit-inline-templates</code> <dd>Don't emit code for implicit instantiations of inline templates, either. The default is to handle inlines differently so that compiles with andwithout optimization will need the same set of explicit instantiations. <br><dt><code>-fno-implement-inlines</code> <dd>To save space, do not emit out-of-line copies of inline functionscontrolled by <code>#pragma implementation</code>. This will cause linkererrors if these functions are not inlined everywhere they are called. <br><dt><code>-fms-extensions</code> <dd>Disable pedantic warnings about constructs used in MFC, such as implicitint and getting a pointer to member function via non-standard syntax. <br><dt><code>-fno-nonansi-builtins</code> <dd>Disable built-in declarations of functions that are not mandated byANSI/ISO C. These include <code>ffs</code>, <code>alloca</code>, <code>_exit</code>,<code>index</code>, <code>bzero</code>, <code>conjf</code>, and other related functions. <br><dt><code>-fno-operator-names</code> <dd>Do not treat the operator name keywords <code>and</code>, <code>bitand</code>,<code>bitor</code>, <code>compl</code>, <code>not</code>, <code>or</code> and <code>xor</code> assynonyms as keywords. <br><dt><code>-fno-optional-diags</code> <dd>Disable diagnostics that the standard says a compiler does not need toissue. Currently, the only such diagnostic issued by G++ is the one fora name having multiple meanings within a class. <br><dt><code>-fpermissive</code> <dd>Downgrade some diagnostics about nonconformant code from errors towarnings. Thus, using <code>-fpermissive</code> will allow somenonconforming code to compile. <br><dt><code>-frepo</code> <dd>Enable automatic template instantiation at link time. This option alsoimplies <code>-fno-implicit-templates</code>. See <a href="Template-Instantiation.html#Template%20Instantiation">Template Instantiation</a>, for more information. <br><dt><code>-fno-rtti</code> <dd>Disable generation of information about every class with virtualfunctions for use by the C++ runtime type identification features(<code>dynamic_cast</code> and <code>typeid</code>). If you don't use those partsof the language, you can save some space by using this flag. Note thatexception handling uses the same information, but it will generate it asneeded. <br><dt><code>-fstats</code> <dd>Emit statistics about front-end processing at the end of the compilation. This information is generally only useful to the G++ development team. <br><dt><code>-ftemplate-depth-</code><var>n</var><code></code> <dd>Set the maximum instantiation depth for template classes to <var>n</var>. A limit on the template instantiation depth is needed to detectendless recursions during template class instantiation. ANSI/ISO C++conforming programs must not rely on a maximum depth greater than 17. <br><dt><code>-fuse-cxa-atexit</code> <dd>Register destructors for objects with static storage duration with the<code>__cxa_atexit</code> function rather than the <code>atexit</code> function. This option is required for fully standards-compliant handling of staticdestructors, but will only work if your C library supports<code>__cxa_atexit</code>. <br><dt><code>-fno-weak</code> <dd>Do not use weak symbol support, even if it is provided by the linker. By default, G++ will use weak symbols if they are available. Thisoption exists only for testing, and should not be used by end-users;it will result in inferior code and has no benefits. This option maybe removed in a future release of G++. <br><dt><code>-nostdinc++</code> <dd>Do not search for header files in the standard directories specific toC++, but do still search the other standard directories. (This optionis used when building the C++ library.) </dl> <p>In addition, these optimization, warning, and code generation optionshave meanings only for C++ programs: <dl><dt><code>-fno-default-inline</code> <dd>Do not assume <code>inline</code> for functions defined inside a class scope.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -