-qlanglvl

This topic includes the following information:

Category

Language element control

Pragma equivalent

#pragma options langlvl, #pragma langlvl

Purpose

Determines whether source code and compiler options should be checked for conformance to a specific language standard, or subset or superset of a standard.

Syntax

Read syntax diagramSkip visual syntax diagram
Option syntax

                    .-:---------------------.   
                    V .-extc99------------. |   
>>- -q--langlvl--=----+-classic-----------+-+------------------><
                      +-extc1x------------+     
                      +-extc89------------+     
                      +-extended----------+     
                      +-saa---------------+     
                      +-saal2-------------+     
                      +-stdc89------------+     
                      +-stdc99------------+     
                      '-feature_suboption-'     

Read syntax diagramSkip visual syntax diagram
Pragma syntax

                          .-extc99---.      
>>-#--pragma--langlvl--(--+-classic--+--)----------------------><
                          +-extc1x---+      
                          +-extc89---+      
                          +-extended-+      
                          +-saa------+      
                          +-saal2----+      
                          +-stdc89---+      
                          '-stdc99---'      

Defaults

Parameters

The following are the -qlanglvl/#pragma langlvl parameters for C language programs:
classic
Allows the compilation of nonstandard programs, and conforms closely to the K&R level preprocessor. This language level is not supported by the AIX® V5.1 and higher system header files, such as math.h. If you use the AIX V5.1 or higher system header files, consider compiling your program to the stdc89 or extended language levels.

For details, see Differences between the classic language level and all other standard-based language levels.

C11
extc1x
Compilation is based on the C11 standard, invoking all the currently supported C11 features and other implementation-specific language extensions. For more information about these C11 features, see Extensions for C11 compatibility
Note: IBM supports selected features of C11, known as C1X before its ratification. IBM will continue to develop and implement the features of this standard. The implementation of the language level is based on IBM's interpretation of the standard. Until IBM's implementation of all the C11 features is complete, including the support of a new C11 standard library, the implementation may change from release to release. IBM makes no attempt to maintain compatibility, in source, binary, or listings and other compiler interfaces, with earlier releases of IBM's implementation of the C11 features.
C11
extc89
Compilation conforms to the ANSI C89 standard, and accepts implementation-specific language extensions.
extc99
Compilation conforms to the ISO C99 standard, and accepts implementation-specific language extensions.
extended
Provides compatibility with the RT compiler and classic. This language level is based on C89.
saa
Compilation conforms to the current SAA C CPI language definition. This is currently SAA C Level 2.
saal2
Compilation conforms to the SAA C Level 2 CPI language definition, with some exceptions.
stdc89
Compilation conforms strictly to the ANSI C89 standard, also known as ISO C90.
stdc99
Compilation conforms strictly to the ISO C99 standard.
Note: Not all operating system releases support the header files and runtime library required by C99.
The -qlanglvl suboption parameters for individual C features are listed as follows:
feature_suboption
feature_suboption in the syntax diagram represents a colon-separated list of the C options. They can be any of the following options:
Note: When multiple -qlanglvl group options and suboptions are specified for one individual C feature, the last one takes effect.
IBM extensiontextafterendif | notextafterendif
Specifies whether to suppress the warning message that is emitted when you are porting code from a compiler that allows extra text after #endif or #else to the IBM® XL C compiler. The default option is -qlanglvl=notextafterendif, indicating that a message is emitted if #else or #endif is followed by any extraneous text. However, when the language level is classic, the default option is -qlanglvl=textafterendif, because this language level already allows extra text after #else or #endif without generating a message.IBM extension
ucs | noucs (option only)
Controls whether Unicode characters are allowed in identifiers, string literals and character literals in program source code. This suboption is enabled by default when stdc99 or extc99 is in effect. For details on the Unicode character set, see The Unicode standard .
The following -qlanglvl suboptions are accepted but ignored by the C compiler. Use extended | extc99 | extc89 to enable the functions that these suboptions imply. For other language levels, the functions implied by these suboptions are disabled.
[no]gnu_assert
GNU C portability option.
[no]gnu_explicitregvar
GNU C portability option.
[no]gnu_include_next
GNU C portability option.
[no]gnu_locallabel
GNU C portability option.
[no]gnu_warning
GNU C portability option.

Usage

Since the pragma directive makes your code non-portable, it is recommended that you use the option rather than the pragma. If you do use the pragma, it must appear before any noncommentary lines in the source code. Also, because the directive can dynamically alter preprocessor behavior, compiling with the preprocessing-only options may produce results different from those produced during regular compilation.

Predefined macros

See Macros related to language levels for a list of macros that are predefined by -qlanglvl suboptions.

Related information