Extensions for GNU C compatibility

The following subset of the GNU C language extensions is enabled with the -qlanglvl=extended option, which is the default language level.

Table 1. Default IBM XL C++ extensions for compatibility with GNU C
Language feature Discussed in:
__alignof__ operator The __alignof__ operator (IBM extension)
__imag__ and __real__ complex type operators The __real__ and __imag__ operators (IBM extension)
__typeof__ operator The typeof operator (IBM extension)
Assembly labels Assembly labels (IBM extension)
Complex type arguments to unary operators Unary expressions
Function attributes Function attributes (IBM extension)
Generalized lvalues Lvalues and rvalues
Placement of flexible array members anywhere in structure or union Flexible array members
Statements and declarations in expressions Statement expressions (IBM extension)
Static initialization of flexible array members of aggregates Flexible array members
The following GNU C language extension is enabled by default at all language levels, and has an individual option control.
Table 2. Default IBM XL C++ extensions for compatibility with GNU C
Language feature Discussed in: Individual option controls
#include_next preprocessor directive The #include_next directive (IBM extension) -qlanglvl=[no]gnu_include_next

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

Table 3. Default IBM XL C++ extensions for compatibility with GNU C, with individual option controls
Language feature Discussed in: Individual option controls
__extension__ keyword Keywords for language extensions (IBM extension) -q[no]keyword=__extension__
#assert, #unassert 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
#warning preprocessor directive The #warning directive (IBM extension) -qlanglvl=[no]gnu_warning
Alternate keywords Keywords for language extensions (IBM extension) -q[no]keyword=token
Complex literal suffixes Complex literals -qlanglvl=[no]gnu_suffixij
Computed goto statements Computed goto statement (IBM extension) -qlanglvl=[no]gnu_computedgoto
Function attributes Function attributes (IBM extension) -q[no]keyword=__attribute__
inline assembly-language statements Inline assembly statements (IBM extension) -qasm
Labels as values Labels as values (IBM extension) -qlanglvl=[no]gnu_labelvalue
Locally declared labels Locally declared labels (IBM extension) -qlanglvl=[no]gnu_locallabel
Type attributes Type attributes (IBM extension) -q[no]keyword=__attribute__
typeof operator The typeof operator (IBM extension) -q[no]keyword=typeof
Variable attributes Variable attributes (IBM extension) -q[no]keyword=__attribute__
Variadic macro extensions Variadic macro extensions(IBM extension) -qlanglvl=[no]gnu_varargmacros
Visibility function attribute visibility (IBM extension) -qvisibility
Visibility variable attribute The visibility variable attribute (IBM extension) -qvisibility
Zero-extent arrays Zero-extent array members (IBM extension) -qlanglvl=[no]zeroextarray
Note: You can use the -qvisibility option to specify visibility attributes for variables and functions if they do not get visibility attributes from pragma directives, explicitly specified attributes, or propagation rules. This option cannot be used to disable visibility attributes for variables or functions.

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

Table 4. 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