1<html lang="en"> 2<head> 3<title>C Dialect Options - Using the GNU Compiler Collection (GCC)</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Using the GNU Compiler Collection (GCC)"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC"> 9<link rel="prev" href="Invoking-G_002b_002b.html#Invoking-G_002b_002b" title="Invoking G++"> 10<link rel="next" href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options" title="C++ Dialect Options"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 152010 Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation; with the 20Invariant Sections being ``Funding Free Software'', the Front-Cover 21Texts being (a) (see below), and with the Back-Cover Texts being (b) 22(see below). A copy of the license is included in the section entitled 23``GNU Free Documentation License''. 24 25(a) The FSF's Front-Cover Text is: 26 27 A GNU Manual 28 29(b) The FSF's Back-Cover Text is: 30 31 You have freedom to copy and modify this GNU Manual, like GNU 32 software. Copies published by the Free Software Foundation raise 33 funds for GNU development.--> 34<meta http-equiv="Content-Style-Type" content="text/css"> 35<style type="text/css"><!-- 36 pre.display { font-family:inherit } 37 pre.format { font-family:inherit } 38 pre.smalldisplay { font-family:inherit; font-size:smaller } 39 pre.smallformat { font-family:inherit; font-size:smaller } 40 pre.smallexample { font-size:smaller } 41 pre.smalllisp { font-size:smaller } 42 span.sc { font-variant:small-caps } 43 span.roman { font-family:serif; font-weight:normal; } 44 span.sansserif { font-family:sans-serif; font-weight:normal; } 45--></style> 46<link rel="stylesheet" type="text/css" href="../cs.css"> 47</head> 48<body> 49<div class="node"> 50<a name="C-Dialect-Options"></a> 51<p> 52Next: <a rel="next" accesskey="n" href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options">C++ Dialect Options</a>, 53Previous: <a rel="previous" accesskey="p" href="Invoking-G_002b_002b.html#Invoking-G_002b_002b">Invoking G++</a>, 54Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a> 55<hr> 56</div> 57 58<h3 class="section">3.4 Options Controlling C Dialect</h3> 59 60<p><a name="index-dialect-options-95"></a><a name="index-language-dialect-options-96"></a><a name="index-options_002c-dialect-97"></a> 61The following options control the dialect of C (or languages derived 62from C, such as C++, Objective-C and Objective-C++) that the compiler 63accepts: 64 65 66<a name="index-ANSI-support-98"></a> 67<a name="index-ISO-support-99"></a> 68<dl><dt><code>-ansi</code><dd><a name="index-ansi-100"></a>In C mode, this is equivalent to ‘<samp><span class="samp">-std=c90</span></samp>’. In C++ mode, it is 69equivalent to ‘<samp><span class="samp">-std=c++98</span></samp>’. 70 71 <p>This turns off certain features of GCC that are incompatible with ISO 72C90 (when compiling C code), or of standard C++ (when compiling C++ code), 73such as the <code>asm</code> and <code>typeof</code> keywords, and 74predefined macros such as <code>unix</code> and <code>vax</code> that identify the 75type of system you are using. It also enables the undesirable and 76rarely used ISO trigraph feature. For the C compiler, 77it disables recognition of C++ style ‘<samp><span class="samp">//</span></samp>’ comments as well as 78the <code>inline</code> keyword. 79 80 <p>The alternate keywords <code>__asm__</code>, <code>__extension__</code>, 81<code>__inline__</code> and <code>__typeof__</code> continue to work despite 82<samp><span class="option">-ansi</span></samp>. You would not want to use them in an ISO C program, of 83course, but it is useful to put them in header files that might be included 84in compilations done with <samp><span class="option">-ansi</span></samp>. Alternate predefined macros 85such as <code>__unix__</code> and <code>__vax__</code> are also available, with or 86without <samp><span class="option">-ansi</span></samp>. 87 88 <p>The <samp><span class="option">-ansi</span></samp> option does not cause non-ISO programs to be 89rejected gratuitously. For that, <samp><span class="option">-pedantic</span></samp> is required in 90addition to <samp><span class="option">-ansi</span></samp>. See <a href="Warning-Options.html#Warning-Options">Warning Options</a>. 91 92 <p>The macro <code>__STRICT_ANSI__</code> is predefined when the <samp><span class="option">-ansi</span></samp> 93option is used. Some header files may notice this macro and refrain 94from declaring certain functions or defining certain macros that the 95ISO standard doesn't call for; this is to avoid interfering with any 96programs that might use these names for other things. 97 98 <p>Functions that would normally be built in but do not have semantics 99defined by ISO C (such as <code>alloca</code> and <code>ffs</code>) are not built-in 100functions when <samp><span class="option">-ansi</span></samp> is used. See <a href="Other-Builtins.html#Other-Builtins">Other built-in functions provided by GCC</a>, for details of the functions 101affected. 102 103 <br><dt><code>-std=</code><dd><a name="index-std-101"></a>Determine the language standard. See <a href="Standards.html#Standards">Language Standards Supported by GCC</a>, for details of these standard versions. This option 104is currently only supported when compiling C or C++. 105 106 <p>The compiler can accept several base standards, such as ‘<samp><span class="samp">c90</span></samp>’ or 107‘<samp><span class="samp">c++98</span></samp>’, and GNU dialects of those standards, such as 108‘<samp><span class="samp">gnu90</span></samp>’ or ‘<samp><span class="samp">gnu++98</span></samp>’. By specifying a base standard, the 109compiler will accept all programs following that standard and those 110using GNU extensions that do not contradict it. For example, 111‘<samp><span class="samp">-std=c90</span></samp>’ turns off certain features of GCC that are 112incompatible with ISO C90, such as the <code>asm</code> and <code>typeof</code> 113keywords, but not other GNU extensions that do not have a meaning in 114ISO C90, such as omitting the middle term of a <code>?:</code> 115expression. On the other hand, by specifying a GNU dialect of a 116standard, all features the compiler support are enabled, even when 117those features change the meaning of the base standard and some 118strict-conforming programs may be rejected. The particular standard 119is used by <samp><span class="option">-pedantic</span></samp> to identify which features are GNU 120extensions given that version of the standard. For example 121‘<samp><span class="samp">-std=gnu90 -pedantic</span></samp>’ would warn about C++ style ‘<samp><span class="samp">//</span></samp>’ 122comments, while ‘<samp><span class="samp">-std=gnu99 -pedantic</span></samp>’ would not. 123 124 <p>A value for this option must be provided; possible values are 125 126 <dl> 127<dt>‘<samp><span class="samp">c90</span></samp>’<dt>‘<samp><span class="samp">c89</span></samp>’<dt>‘<samp><span class="samp">iso9899:1990</span></samp>’<dd>Support all ISO C90 programs (certain GNU extensions that conflict 128with ISO C90 are disabled). Same as <samp><span class="option">-ansi</span></samp> for C code. 129 130 <br><dt>‘<samp><span class="samp">iso9899:199409</span></samp>’<dd>ISO C90 as modified in amendment 1. 131 132 <br><dt>‘<samp><span class="samp">c99</span></samp>’<dt>‘<samp><span class="samp">c9x</span></samp>’<dt>‘<samp><span class="samp">iso9899:1999</span></samp>’<dt>‘<samp><span class="samp">iso9899:199x</span></samp>’<dd>ISO C99. Note that this standard is not yet fully supported; see 133<a href="http://gcc.gnu.org/gcc-4.6/c99status.html">http://gcc.gnu.org/gcc-4.6/c99status.html</a><!-- /@w --> for more information. The 134names ‘<samp><span class="samp">c9x</span></samp>’ and ‘<samp><span class="samp">iso9899:199x</span></samp>’ are deprecated. 135 136 <br><dt>‘<samp><span class="samp">c1x</span></samp>’<dd>ISO C1X, the draft of the next revision of the ISO C standard. 137Support is limited and experimental and features enabled by this 138option may be changed or removed if changed in or removed from the 139standard draft. 140 141 <br><dt>‘<samp><span class="samp">gnu90</span></samp>’<dt>‘<samp><span class="samp">gnu89</span></samp>’<dd>GNU dialect of ISO C90 (including some C99 features). This 142is the default for C code. 143 144 <br><dt>‘<samp><span class="samp">gnu99</span></samp>’<dt>‘<samp><span class="samp">gnu9x</span></samp>’<dd>GNU dialect of ISO C99. When ISO C99 is fully implemented in GCC, 145this will become the default. The name ‘<samp><span class="samp">gnu9x</span></samp>’ is deprecated. 146 147 <br><dt>‘<samp><span class="samp">gnu1x</span></samp>’<dd>GNU dialect of ISO C1X. Support is limited and experimental and 148features enabled by this option may be changed or removed if changed 149in or removed from the standard draft. 150 151 <br><dt>‘<samp><span class="samp">c++98</span></samp>’<dd>The 1998 ISO C++ standard plus amendments. Same as <samp><span class="option">-ansi</span></samp> for 152C++ code. 153 154 <br><dt>‘<samp><span class="samp">gnu++98</span></samp>’<dd>GNU dialect of <samp><span class="option">-std=c++98</span></samp>. This is the default for 155C++ code. 156 157 <br><dt>‘<samp><span class="samp">c++0x</span></samp>’<dd>The working draft of the upcoming ISO C++0x standard. This option 158enables experimental features that are likely to be included in 159C++0x. The working draft is constantly changing, and any feature that is 160enabled by this flag may be removed from future versions of GCC if it is 161not part of the C++0x standard. 162 163 <br><dt>‘<samp><span class="samp">gnu++0x</span></samp>’<dd>GNU dialect of <samp><span class="option">-std=c++0x</span></samp>. This option enables 164experimental features that may be removed in future versions of GCC. 165</dl> 166 167 <br><dt><code>-fgnu89-inline</code><dd><a name="index-fgnu89_002dinline-102"></a>The option <samp><span class="option">-fgnu89-inline</span></samp> tells GCC to use the traditional 168GNU semantics for <code>inline</code> functions when in C99 mode. 169See <a href="Inline.html#Inline">An Inline Function is As Fast As a Macro</a>. This option 170is accepted and ignored by GCC versions 4.1.3 up to but not including 1714.3. In GCC versions 4.3 and later it changes the behavior of GCC in 172C99 mode. Using this option is roughly equivalent to adding the 173<code>gnu_inline</code> function attribute to all inline functions 174(see <a href="Function-Attributes.html#Function-Attributes">Function Attributes</a>). 175 176 <p>The option <samp><span class="option">-fno-gnu89-inline</span></samp> explicitly tells GCC to use the 177C99 semantics for <code>inline</code> when in C99 or gnu99 mode (i.e., it 178specifies the default behavior). This option was first supported in 179GCC 4.3. This option is not supported in <samp><span class="option">-std=c90</span></samp> or 180<samp><span class="option">-std=gnu90</span></samp> mode. 181 182 <p>The preprocessor macros <code>__GNUC_GNU_INLINE__</code> and 183<code>__GNUC_STDC_INLINE__</code> may be used to check which semantics are 184in effect for <code>inline</code> functions. See <a href="../cpp/Common-Predefined-Macros.html#Common-Predefined-Macros">Common Predefined Macros</a>. 185 186 <br><dt><code>-aux-info </code><var>filename</var><dd><a name="index-aux_002dinfo-103"></a>Output to the given filename prototyped declarations for all functions 187declared and/or defined in a translation unit, including those in header 188files. This option is silently ignored in any language other than C. 189 190 <p>Besides declarations, the file indicates, in comments, the origin of 191each declaration (source file and line), whether the declaration was 192implicit, prototyped or unprototyped (‘<samp><span class="samp">I</span></samp>’, ‘<samp><span class="samp">N</span></samp>’ for new or 193‘<samp><span class="samp">O</span></samp>’ for old, respectively, in the first character after the line 194number and the colon), and whether it came from a declaration or a 195definition (‘<samp><span class="samp">C</span></samp>’ or ‘<samp><span class="samp">F</span></samp>’, respectively, in the following 196character). In the case of function definitions, a K&R-style list of 197arguments followed by their declarations is also provided, inside 198comments, after the declaration. 199 200 <br><dt><code>-fno-asm</code><dd><a name="index-fno_002dasm-104"></a>Do not recognize <code>asm</code>, <code>inline</code> or <code>typeof</code> as a 201keyword, so that code can use these words as identifiers. You can use 202the keywords <code>__asm__</code>, <code>__inline__</code> and <code>__typeof__</code> 203instead. <samp><span class="option">-ansi</span></samp> implies <samp><span class="option">-fno-asm</span></samp>. 204 205 <p>In C++, this switch only affects the <code>typeof</code> keyword, since 206<code>asm</code> and <code>inline</code> are standard keywords. You may want to 207use the <samp><span class="option">-fno-gnu-keywords</span></samp> flag instead, which has the same 208effect. In C99 mode (<samp><span class="option">-std=c99</span></samp> or <samp><span class="option">-std=gnu99</span></samp>), this 209switch only affects the <code>asm</code> and <code>typeof</code> keywords, since 210<code>inline</code> is a standard keyword in ISO C99. 211 212 <br><dt><code>-fno-builtin</code><dt><code>-fno-builtin-</code><var>function</var><dd><a name="index-fno_002dbuiltin-105"></a><a name="index-built_002din-functions-106"></a>Don't recognize built-in functions that do not begin with 213‘<samp><span class="samp">__builtin_</span></samp>’ as prefix. See <a href="Other-Builtins.html#Other-Builtins">Other built-in functions provided by GCC</a>, for details of the functions affected, 214including those which are not built-in functions when <samp><span class="option">-ansi</span></samp> or 215<samp><span class="option">-std</span></samp> options for strict ISO C conformance are used because they 216do not have an ISO standard meaning. 217 218 <p>GCC normally generates special code to handle certain built-in functions 219more efficiently; for instance, calls to <code>alloca</code> may become single 220instructions that adjust the stack directly, and calls to <code>memcpy</code> 221may become inline copy loops. The resulting code is often both smaller 222and faster, but since the function calls no longer appear as such, you 223cannot set a breakpoint on those calls, nor can you change the behavior 224of the functions by linking with a different library. In addition, 225when a function is recognized as a built-in function, GCC may use 226information about that function to warn about problems with calls to 227that function, or to generate more efficient code, even if the 228resulting code still contains calls to that function. For example, 229warnings are given with <samp><span class="option">-Wformat</span></samp> for bad calls to 230<code>printf</code>, when <code>printf</code> is built in, and <code>strlen</code> is 231known not to modify global memory. 232 233 <p>With the <samp><span class="option">-fno-builtin-</span><var>function</var></samp> option 234only the built-in function <var>function</var> is 235disabled. <var>function</var> must not begin with ‘<samp><span class="samp">__builtin_</span></samp>’. If a 236function is named that is not built-in in this version of GCC, this 237option is ignored. There is no corresponding 238<samp><span class="option">-fbuiltin-</span><var>function</var></samp> option; if you wish to enable 239built-in functions selectively when using <samp><span class="option">-fno-builtin</span></samp> or 240<samp><span class="option">-ffreestanding</span></samp>, you may define macros such as: 241 242 <pre class="smallexample"> #define abs(n) __builtin_abs ((n)) 243 #define strcpy(d, s) __builtin_strcpy ((d), (s)) 244</pre> 245 <br><dt><code>-fhosted</code><dd><a name="index-fhosted-107"></a><a name="index-hosted-environment-108"></a> 246Assert that compilation takes place in a hosted environment. This implies 247<samp><span class="option">-fbuiltin</span></samp>. A hosted environment is one in which the 248entire standard library is available, and in which <code>main</code> has a return 249type of <code>int</code>. Examples are nearly everything except a kernel. 250This is equivalent to <samp><span class="option">-fno-freestanding</span></samp>. 251 252 <br><dt><code>-ffreestanding</code><dd><a name="index-ffreestanding-109"></a><a name="index-hosted-environment-110"></a> 253Assert that compilation takes place in a freestanding environment. This 254implies <samp><span class="option">-fno-builtin</span></samp>. A freestanding environment 255is one in which the standard library may not exist, and program startup may 256not necessarily be at <code>main</code>. The most obvious example is an OS kernel. 257This is equivalent to <samp><span class="option">-fno-hosted</span></samp>. 258 259 <p>See <a href="Standards.html#Standards">Language Standards Supported by GCC</a>, for details of 260freestanding and hosted environments. 261 262 <br><dt><code>-fopenmp</code><dd><a name="index-fopenmp-111"></a><a name="index-OpenMP-parallel-112"></a>Enable handling of OpenMP directives <code>#pragma omp</code> in C/C++ and 263<code>!$omp</code> in Fortran. When <samp><span class="option">-fopenmp</span></samp> is specified, the 264compiler generates parallel code according to the OpenMP Application 265Program Interface v3.0 <a href="http://www.openmp.org/">http://www.openmp.org/</a><!-- /@w -->. This option 266implies <samp><span class="option">-pthread</span></samp>, and thus is only supported on targets that 267have support for <samp><span class="option">-pthread</span></samp>. 268 269 <br><dt><code>-fms-extensions</code><dd><a name="index-fms_002dextensions-113"></a>Accept some non-standard constructs used in Microsoft header files. 270 271 <p>In C++ code, this allows member names in structures to be similar 272to previous types declarations. 273 274 <pre class="smallexample"> typedef int UOW; 275 struct ABC { 276 UOW UOW; 277 }; 278</pre> 279 <p>Some cases of unnamed fields in structures and unions are only 280accepted with this option. See <a href="Unnamed-Fields.html#Unnamed-Fields">Unnamed struct/union fields within structs/unions</a>, for details. 281 282 <br><dt><code>-fplan9-extensions</code><dd>Accept some non-standard constructs used in Plan 9 code. 283 284 <p>This enables <samp><span class="option">-fms-extensions</span></samp>, permits passing pointers to 285structures with anonymous fields to functions which expect pointers to 286elements of the type of the field, and permits referring to anonymous 287fields declared using a typedef. See <a href="Unnamed-Fields.html#Unnamed-Fields">Unnamed struct/union fields within structs/unions</a>, for details. This is only 288supported for C, not C++. 289 290 <br><dt><code>-trigraphs</code><dd><a name="index-trigraphs-114"></a>Support ISO C trigraphs. The <samp><span class="option">-ansi</span></samp> option (and <samp><span class="option">-std</span></samp> 291options for strict ISO C conformance) implies <samp><span class="option">-trigraphs</span></samp>. 292 293 <br><dt><code>-no-integrated-cpp</code><dd><a name="index-no_002dintegrated_002dcpp-115"></a>Performs a compilation in two passes: preprocessing and compiling. This 294option allows a user supplied "cc1", "cc1plus", or "cc1obj" via the 295<samp><span class="option">-B</span></samp> option. The user supplied compilation step can then add in 296an additional preprocessing step after normal preprocessing but before 297compiling. The default is to use the integrated cpp (internal cpp) 298 299 <p>The semantics of this option will change if "cc1", "cc1plus", and 300"cc1obj" are merged. 301 302 <p><a name="index-traditional-C-language-116"></a><a name="index-C-language_002c-traditional-117"></a><br><dt><code>-traditional</code><dt><code>-traditional-cpp</code><dd><a name="index-traditional_002dcpp-118"></a><a name="index-traditional-119"></a>Formerly, these options caused GCC to attempt to emulate a pre-standard 303C compiler. They are now only supported with the <samp><span class="option">-E</span></samp> switch. 304The preprocessor continues to support a pre-standard mode. See the GNU 305CPP manual for details. 306 307 <br><dt><code>-fcond-mismatch</code><dd><a name="index-fcond_002dmismatch-120"></a>Allow conditional expressions with mismatched types in the second and 308third arguments. The value of such an expression is void. This option 309is not supported for C++. 310 311 <br><dt><code>-flax-vector-conversions</code><dd><a name="index-flax_002dvector_002dconversions-121"></a>Allow implicit conversions between vectors with differing numbers of 312elements and/or incompatible element types. This option should not be 313used for new code. 314 315 <br><dt><code>-funsigned-char</code><dd><a name="index-funsigned_002dchar-122"></a>Let the type <code>char</code> be unsigned, like <code>unsigned char</code>. 316 317 <p>Each kind of machine has a default for what <code>char</code> should 318be. It is either like <code>unsigned char</code> by default or like 319<code>signed char</code> by default. 320 321 <p>Ideally, a portable program should always use <code>signed char</code> or 322<code>unsigned char</code> when it depends on the signedness of an object. 323But many programs have been written to use plain <code>char</code> and 324expect it to be signed, or expect it to be unsigned, depending on the 325machines they were written for. This option, and its inverse, let you 326make such a program work with the opposite default. 327 328 <p>The type <code>char</code> is always a distinct type from each of 329<code>signed char</code> or <code>unsigned char</code>, even though its behavior 330is always just like one of those two. 331 332 <br><dt><code>-fsigned-char</code><dd><a name="index-fsigned_002dchar-123"></a>Let the type <code>char</code> be signed, like <code>signed char</code>. 333 334 <p>Note that this is equivalent to <samp><span class="option">-fno-unsigned-char</span></samp>, which is 335the negative form of <samp><span class="option">-funsigned-char</span></samp>. Likewise, the option 336<samp><span class="option">-fno-signed-char</span></samp> is equivalent to <samp><span class="option">-funsigned-char</span></samp>. 337 338 <br><dt><code>-fsigned-bitfields</code><dt><code>-funsigned-bitfields</code><dt><code>-fno-signed-bitfields</code><dt><code>-fno-unsigned-bitfields</code><dd><a name="index-fsigned_002dbitfields-124"></a><a name="index-funsigned_002dbitfields-125"></a><a name="index-fno_002dsigned_002dbitfields-126"></a><a name="index-fno_002dunsigned_002dbitfields-127"></a>These options control whether a bit-field is signed or unsigned, when the 339declaration does not use either <code>signed</code> or <code>unsigned</code>. By 340default, such a bit-field is signed, because this is consistent: the 341basic integer types such as <code>int</code> are signed types. 342</dl> 343 344 </body></html> 345 346