gcc: C Dialect Options

1 
1 3.4 Options Controlling C Dialect
1 =================================
1 
1 The following options control the dialect of C (or languages derived
1 from C, such as C++, Objective-C and Objective-C++) that the compiler
1 accepts:
1 
1 '-ansi'
1      In C mode, this is equivalent to '-std=c90'.  In C++ mode, it is
1      equivalent to '-std=c++98'.
1 
1      This turns off certain features of GCC that are incompatible with
1      ISO C90 (when compiling C code), or of standard C++ (when compiling
1      C++ code), such as the 'asm' and 'typeof' keywords, and predefined
1      macros such as 'unix' and 'vax' that identify the type of system
1      you are using.  It also enables the undesirable and rarely used ISO
1      trigraph feature.  For the C compiler, it disables recognition of
1      C++ style '//' comments as well as the 'inline' keyword.
1 
1      The alternate keywords '__asm__', '__extension__', '__inline__' and
1      '__typeof__' continue to work despite '-ansi'.  You would not want
1      to use them in an ISO C program, of course, but it is useful to put
1      them in header files that might be included in compilations done
1      with '-ansi'.  Alternate predefined macros such as '__unix__' and
1      '__vax__' are also available, with or without '-ansi'.
1 
1      The '-ansi' option does not cause non-ISO programs to be rejected
1      gratuitously.  For that, '-Wpedantic' is required in addition to
1      '-ansi'.  ⇒Warning Options.
1 
1      The macro '__STRICT_ANSI__' is predefined when the '-ansi' option
1      is used.  Some header files may notice this macro and refrain from
1      declaring certain functions or defining certain macros that the ISO
1      standard doesn't call for; this is to avoid interfering with any
1      programs that might use these names for other things.
1 
1      Functions that are normally built in but do not have semantics
1      defined by ISO C (such as 'alloca' and 'ffs') are not built-in
11      functions when '-ansi' is used.  ⇒Other built-in functions
      provided by GCC Other Builtins, for details of the functions
1      affected.
1 
1 '-std='
11      Determine the language standard.  ⇒Language Standards
      Supported by GCC Standards, for details of these standard
1      versions.  This option is currently only supported when compiling C
1      or C++.
1 
1      The compiler can accept several base standards, such as 'c90' or
1      'c++98', and GNU dialects of those standards, such as 'gnu90' or
1      'gnu++98'.  When a base standard is specified, the compiler accepts
1      all programs following that standard plus those using GNU
1      extensions that do not contradict it.  For example, '-std=c90'
1      turns off certain features of GCC that are incompatible with ISO
1      C90, such as the 'asm' and 'typeof' keywords, but not other GNU
1      extensions that do not have a meaning in ISO C90, such as omitting
1      the middle term of a '?:' expression.  On the other hand, when a
1      GNU dialect of a standard is specified, all features supported by
1      the compiler are enabled, even when those features change the
1      meaning of the base standard.  As a result, some strict-conforming
1      programs may be rejected.  The particular standard is used by
1      '-Wpedantic' to identify which features are GNU extensions given
1      that version of the standard.  For example '-std=gnu90 -Wpedantic'
1      warns about C++ style '//' comments, while '-std=gnu99 -Wpedantic'
1      does not.
1 
1      A value for this option must be provided; possible values are
1 
1      'c90'
1      'c89'
1      'iso9899:1990'
1           Support all ISO C90 programs (certain GNU extensions that
1           conflict with ISO C90 are disabled).  Same as '-ansi' for C
1           code.
1 
1      'iso9899:199409'
1           ISO C90 as modified in amendment 1.
1 
1      'c99'
1      'c9x'
1      'iso9899:1999'
1      'iso9899:199x'
1           ISO C99.  This standard is substantially completely supported,
1           modulo bugs and floating-point issues (mainly but not entirely
1           relating to optional C99 features from Annexes F and G). See
1           <http://gcc.gnu.org/c99status.html> for more information.  The
1           names 'c9x' and 'iso9899:199x' are deprecated.
1 
1      'c11'
1      'c1x'
1      'iso9899:2011'
1           ISO C11, the 2011 revision of the ISO C standard.  This
1           standard is substantially completely supported, modulo bugs,
1           floating-point issues (mainly but not entirely relating to
1           optional C11 features from Annexes F and G) and the optional
1           Annexes K (Bounds-checking interfaces) and L (Analyzability).
1           The name 'c1x' is deprecated.
1 
1      'c17'
1      'c18'
1      'iso9899:2017'
1      'iso9899:2018'
1           ISO C17, the 2017 revision of the ISO C standard (expected to
1           be published in 2018).  This standard is same as C11 except
1           for corrections of defects (all of which are also applied with
1           '-std=c11') and a new value of '__STDC_VERSION__', and so is
1           supported to the same extent as C11.
1 
1      'gnu90'
1      'gnu89'
1           GNU dialect of ISO C90 (including some C99 features).
1 
1      'gnu99'
1      'gnu9x'
1           GNU dialect of ISO C99.  The name 'gnu9x' is deprecated.
1 
1      'gnu11'
1      'gnu1x'
1           GNU dialect of ISO C11.  The name 'gnu1x' is deprecated.
1 
1      'gnu17'
1      'gnu18'
1           GNU dialect of ISO C17.  This is the default for C code.
1 
1      'c++98'
1      'c++03'
1           The 1998 ISO C++ standard plus the 2003 technical corrigendum
1           and some additional defect reports.  Same as '-ansi' for C++
1           code.
1 
1      'gnu++98'
1      'gnu++03'
1           GNU dialect of '-std=c++98'.
1 
1      'c++11'
1      'c++0x'
1           The 2011 ISO C++ standard plus amendments.  The name 'c++0x'
1           is deprecated.
1 
1      'gnu++11'
1      'gnu++0x'
1           GNU dialect of '-std=c++11'.  The name 'gnu++0x' is
1           deprecated.
1 
1      'c++14'
1      'c++1y'
1           The 2014 ISO C++ standard plus amendments.  The name 'c++1y'
1           is deprecated.
1 
1      'gnu++14'
1      'gnu++1y'
1           GNU dialect of '-std=c++14'.  This is the default for C++
1           code.  The name 'gnu++1y' is deprecated.
1 
1      'c++17'
1      'c++1z'
1           The 2017 ISO C++ standard plus amendments.  The name 'c++1z'
1           is deprecated.
1 
1      'gnu++17'
1      'gnu++1z'
1           GNU dialect of '-std=c++17'.  The name 'gnu++1z' is
1           deprecated.
1 
1      'c++2a'
1           The next revision of the ISO C++ standard, tentatively planned
1           for 2020.  Support is highly experimental, and will almost
1           certainly change in incompatible ways in future releases.
1 
1      'gnu++2a'
1           GNU dialect of '-std=c++2a'.  Support is highly experimental,
1           and will almost certainly change in incompatible ways in
1           future releases.
1 
1 '-fgnu89-inline'
1      The option '-fgnu89-inline' tells GCC to use the traditional GNU
11      semantics for 'inline' functions when in C99 mode.  ⇒An Inline
      Function is As Fast As a Macro Inline.  Using this option is
1      roughly equivalent to adding the 'gnu_inline' function attribute to
1      all inline functions (⇒Function Attributes).
1 
1      The option '-fno-gnu89-inline' explicitly tells GCC to use the C99
1      semantics for 'inline' when in C99 or gnu99 mode (i.e., it
1      specifies the default behavior).  This option is not supported in
1      '-std=c90' or '-std=gnu90' mode.
1 
1      The preprocessor macros '__GNUC_GNU_INLINE__' and
1      '__GNUC_STDC_INLINE__' may be used to check which semantics are in
11      effect for 'inline' functions.  ⇒(cpp)Common Predefined
      Macros.
1 
1 '-fpermitted-flt-eval-methods=STYLE'
1      ISO/IEC TS 18661-3 defines new permissible values for
1      'FLT_EVAL_METHOD' that indicate that operations and constants with
1      a semantic type that is an interchange or extended format should be
1      evaluated to the precision and range of that type.  These new
1      values are a superset of those permitted under C99/C11, which does
1      not specify the meaning of other positive values of
1      'FLT_EVAL_METHOD'.  As such, code conforming to C11 may not have
1      been written expecting the possibility of the new values.
1 
1      '-fpermitted-flt-eval-methods' specifies whether the compiler
1      should allow only the values of 'FLT_EVAL_METHOD' specified in
1      C99/C11, or the extended set of values specified in ISO/IEC TS
1      18661-3.
1 
1      STYLE is either 'c11' or 'ts-18661-3' as appropriate.
1 
1      The default when in a standards compliant mode ('-std=c11' or
1      similar) is '-fpermitted-flt-eval-methods=c11'.  The default when
1      in a GNU dialect ('-std=gnu11' or similar) is
1      '-fpermitted-flt-eval-methods=ts-18661-3'.
1 
1 '-aux-info FILENAME'
1      Output to the given filename prototyped declarations for all
1      functions declared and/or defined in a translation unit, including
1      those in header files.  This option is silently ignored in any
1      language other than C.
1 
1      Besides declarations, the file indicates, in comments, the origin
1      of each declaration (source file and line), whether the declaration
1      was implicit, prototyped or unprototyped ('I', 'N' for new or 'O'
1      for old, respectively, in the first character after the line number
1      and the colon), and whether it came from a declaration or a
1      definition ('C' or 'F', respectively, in the following character).
1      In the case of function definitions, a K&R-style list of arguments
1      followed by their declarations is also provided, inside comments,
1      after the declaration.
1 
1 '-fallow-parameterless-variadic-functions'
1      Accept variadic functions without named parameters.
1 
1      Although it is possible to define such a function, this is not very
1      useful as it is not possible to read the arguments.  This is only
1      supported for C as this construct is allowed by C++.
1 
1 '-fno-asm'
1      Do not recognize 'asm', 'inline' or 'typeof' as a keyword, so that
1      code can use these words as identifiers.  You can use the keywords
1      '__asm__', '__inline__' and '__typeof__' instead.  '-ansi' implies
1      '-fno-asm'.
1 
1      In C++, this switch only affects the 'typeof' keyword, since 'asm'
1      and 'inline' are standard keywords.  You may want to use the
1      '-fno-gnu-keywords' flag instead, which has the same effect.  In
1      C99 mode ('-std=c99' or '-std=gnu99'), this switch only affects the
1      'asm' and 'typeof' keywords, since 'inline' is a standard keyword
1      in ISO C99.
1 
1 '-fno-builtin'
1 '-fno-builtin-FUNCTION'
1      Don't recognize built-in functions that do not begin with
11      '__builtin_' as prefix.  ⇒Other built-in functions provided by
      GCC Other Builtins, for details of the functions affected,
1      including those which are not built-in functions when '-ansi' or
1      '-std' options for strict ISO C conformance are used because they
1      do not have an ISO standard meaning.
1 
1      GCC normally generates special code to handle certain built-in
1      functions more efficiently; for instance, calls to 'alloca' may
1      become single instructions which adjust the stack directly, and
1      calls to 'memcpy' may become inline copy loops.  The resulting code
1      is often both smaller and faster, but since the function calls no
1      longer appear as such, you cannot set a breakpoint on those calls,
1      nor can you change the behavior of the functions by linking with a
1      different library.  In addition, when a function is recognized as a
1      built-in function, GCC may use information about that function to
1      warn about problems with calls to that function, or to generate
1      more efficient code, even if the resulting code still contains
1      calls to that function.  For example, warnings are given with
1      '-Wformat' for bad calls to 'printf' when 'printf' is built in and
1      'strlen' is known not to modify global memory.
1 
1      With the '-fno-builtin-FUNCTION' option only the built-in function
1      FUNCTION is disabled.  FUNCTION must not begin with '__builtin_'.
1      If a function is named that is not built-in in this version of GCC,
1      this option is ignored.  There is no corresponding
1      '-fbuiltin-FUNCTION' option; if you wish to enable built-in
1      functions selectively when using '-fno-builtin' or
1      '-ffreestanding', you may define macros such as:
1 
1           #define abs(n)          __builtin_abs ((n))
1           #define strcpy(d, s)    __builtin_strcpy ((d), (s))
1 
1 '-fgimple'
1 
1      Enable parsing of function definitions marked with '__GIMPLE'.
1      This is an experimental feature that allows unit testing of GIMPLE
1      passes.
1 
1 '-fhosted'
1 
1      Assert that compilation targets a hosted environment.  This implies
1      '-fbuiltin'.  A hosted environment is one in which the entire
1      standard library is available, and in which 'main' has a return
1      type of 'int'.  Examples are nearly everything except a kernel.
1      This is equivalent to '-fno-freestanding'.
1 
1 '-ffreestanding'
1 
1      Assert that compilation targets a freestanding environment.  This
1      implies '-fno-builtin'.  A freestanding environment is one in which
1      the standard library may not exist, and program startup may not
1      necessarily be at 'main'.  The most obvious example is an OS
1      kernel.  This is equivalent to '-fno-hosted'.
1 
1      ⇒Language Standards Supported by GCC Standards, for details
1      of freestanding and hosted environments.
1 
1 '-fopenacc'
1      Enable handling of OpenACC directives '#pragma acc' in C/C++ and
1      '!$acc' in Fortran.  When '-fopenacc' is specified, the compiler
1      generates accelerated code according to the OpenACC Application
1      Programming Interface v2.0 <https://www.openacc.org>.  This option
1      implies '-pthread', and thus is only supported on targets that have
1      support for '-pthread'.
1 
1 '-fopenacc-dim=GEOM'
1      Specify default compute dimensions for parallel offload regions
1      that do not explicitly specify.  The GEOM value is a triple of
1      ':'-separated sizes, in order 'gang', 'worker' and, 'vector'.  A
1      size can be omitted, to use a target-specific default value.
1 
1 '-fopenmp'
1      Enable handling of OpenMP directives '#pragma omp' in C/C++ and
1      '!$omp' in Fortran.  When '-fopenmp' is specified, the compiler
1      generates parallel code according to the OpenMP Application Program
1      Interface v4.5 <http://www.openmp.org/>.  This option implies
1      '-pthread', and thus is only supported on targets that have support
1      for '-pthread'.  '-fopenmp' implies '-fopenmp-simd'.
1 
1 '-fopenmp-simd'
1      Enable handling of OpenMP's SIMD directives with '#pragma omp' in
1      C/C++ and '!$omp' in Fortran.  Other OpenMP directives are ignored.
1 
1 '-fgnu-tm'
1      When the option '-fgnu-tm' is specified, the compiler generates
1      code for the Linux variant of Intel's current Transactional Memory
1      ABI specification document (Revision 1.1, May 6 2009).  This is an
1      experimental feature whose interface may change in future versions
1      of GCC, as the official specification changes.  Please note that
1      not all architectures are supported for this feature.
1 
1      For more information on GCC's support for transactional memory,
11      ⇒The GNU Transactional Memory Library (libitm)Enabling
      libitm.
1 
1      Note that the transactional memory feature is not supported with
1      non-call exceptions ('-fnon-call-exceptions').
1 
1 '-fms-extensions'
1      Accept some non-standard constructs used in Microsoft header files.
1 
1      In C++ code, this allows member names in structures to be similar
1      to previous types declarations.
1 
1           typedef int UOW;
1           struct ABC {
1             UOW UOW;
1           };
1 
1      Some cases of unnamed fields in structures and unions are only
11      accepted with this option.  ⇒Unnamed struct/union fields
      within structs/unions Unnamed Fields, for details.
1 
1      Note that this option is off for all targets but x86 targets using
1      ms-abi.
1 
1 '-fplan9-extensions'
1      Accept some non-standard constructs used in Plan 9 code.
1 
1      This enables '-fms-extensions', permits passing pointers to
1      structures with anonymous fields to functions that expect pointers
1      to elements of the type of the field, and permits referring to
11      anonymous fields declared using a typedef.  ⇒Unnamed
      struct/union fields within structs/unions Unnamed Fields, for
1      details.  This is only supported for C, not C++.
1 
1 '-fcond-mismatch'
1      Allow conditional expressions with mismatched types in the second
1      and third arguments.  The value of such an expression is void.
1      This option is not supported for C++.
1 
1 '-flax-vector-conversions'
1      Allow implicit conversions between vectors with differing numbers
1      of elements and/or incompatible element types.  This option should
1      not be used for new code.
1 
1 '-funsigned-char'
1      Let the type 'char' be unsigned, like 'unsigned char'.
1 
1      Each kind of machine has a default for what 'char' should be.  It
1      is either like 'unsigned char' by default or like 'signed char' by
1      default.
1 
1      Ideally, a portable program should always use 'signed char' or
1      'unsigned char' when it depends on the signedness of an object.
1      But many programs have been written to use plain 'char' and expect
1      it to be signed, or expect it to be unsigned, depending on the
1      machines they were written for.  This option, and its inverse, let
1      you make such a program work with the opposite default.
1 
1      The type 'char' is always a distinct type from each of 'signed
1      char' or 'unsigned char', even though its behavior is always just
1      like one of those two.
1 
1 '-fsigned-char'
1      Let the type 'char' be signed, like 'signed char'.
1 
1      Note that this is equivalent to '-fno-unsigned-char', which is the
1      negative form of '-funsigned-char'.  Likewise, the option
1      '-fno-signed-char' is equivalent to '-funsigned-char'.
1 
1 '-fsigned-bitfields'
1 '-funsigned-bitfields'
1 '-fno-signed-bitfields'
1 '-fno-unsigned-bitfields'
1      These options control whether a bit-field is signed or unsigned,
1      when the declaration does not use either 'signed' or 'unsigned'.
1      By default, such a bit-field is signed, because this is consistent:
1      the basic integer types such as 'int' are signed types.
1 
1 '-fsso-struct=ENDIANNESS'
1      Set the default scalar storage order of structures and unions to
1      the specified endianness.  The accepted values are 'big-endian',
1      'little-endian' and 'native' for the native endianness of the
1      target (the default).  This option is not supported for C++.
1 
1      *Warning:* the '-fsso-struct' switch causes GCC to generate code
1      that is not binary compatible with code generated without it if the
1      specified endianness is not the native endianness of the target.
1