Extensions for GNU C compatibility

The following subset of the GNU C language extensions is enabled by default.

Table 1. Default IBM XL C++ extensions for compatibility with GNU C
Language feature Discussed in:
Assembly labels Assembly labels (IBM extension)
Placement of flexible array members anywhere in structure or union Flexible array members
Static initialization of flexible array members of aggregates Flexible array members
Statements and declarations in expressions Statement expressions (IBM extension)
__alignof__ operator The __alignof__ operator (IBM extension)
__typeof__ operator The typeof operator (IBM extension)
Generalized lvalues Lvalues and rvalues
Complex type arguments to unary operators Unary expressions
__imag__ and __real__ complex type operators The __real__ and __imag__ operators (C only) (IBM extension)
Function attributes Function attributes (IBM extension)

The following subset of the GNU C language extensions is enabled by default. These extensions can also be enabled or disabled by specific compiler options, which are listed in the below table:

Table 2. Default IBM XL C++ extensions for compatibility with GNU C, with individual option controls
Language feature Discussed in: Individual option controls
Alternate keywords Keywords for language extensions (IBM extension) -q[no]keyword=token
__extension__ keyword Keywords for language extensions (IBM extension) -q[no]keyword=__extension__
Complex literal suffixes Complex literals -qlanglvl=[no]gnu_suffixij
Type attributes Type attributes (IBM extension) -q[no]keyword=__attribute__
Variable attributes Variable attributes (IBM extension) -q[no]keyword=__attribute__
Zero-extent arrays Zero-extent array members (IBM extension) -qlanglvl=[no]zeroextarray
typeof operator The typeof operator (IBM extension) -q[no]keyword=typeof
Locally declared labels Locally declared labels (IBM extension) -qlanglvl=[no]gnu_locallabel
Labels as values Labels as values (IBM extension) -qlanglvl=[no]gnu_labelvalue
Computed goto statements Computed goto statement (IBM extension) -qlanglvl=[no]gnu_computedgoto
inline assembly-language statements Inline assembly statements (C only) (IBM extension) -qasm
Variadic macro extensions Variadic macro extensions(IBM extension) -qlanglvl=[no]gnu_varargmacros
#warning preprocessor directive The #warning directive (IBM extension) -qlanglvl=[no]gnu_warning
#assert, #unassert, #cpu, #machine, #system preprocessor directives Assertion directives (IBM extension) -qlanglvl=[no]gnu_assert
#include_next preprocessor directive The #include_next directive (IBM extension) -qlanglvl=[no]gnu_include_next

The following feature requires compilation with the use of an additional option, listed in the below table:

Table 3. IBM XL C++ extensions for GNU C compatibility, requiring additional compiler options
Language feature Discussed in: Required compilation option
Dollar signs in identifiers Characters in identifiers -qdollar