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