-std (-qlanglvl)

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
-qlanglvl syntax (C only)

                    .-extc99---.   
>>- -q--langlvl--=--+-stdc89---+-------------------------------><
                    +-extc89---+   
                    +-stdc99---+   
                    +-extended-+   
                    +-stdc11---+   
                    '-extc1x---'   

Read syntax diagramSkip visual syntax diagram
-std syntax (C only)

             .-gnu9x----------.   
             +-gnu99----------+   
>>- -std--=--+-c89------------+--------------------------------><
             +-c90------------+   
             +-c99------------+   
             +-c9x------------+   
             +-c11------------+   
             +-c1x------------+   
             +-iso9899:1990---+   
             +-iso9899:199409-+   
             +-iso9899:1999---+   
             +-iso9899:199x---+   
             +-iso9899:2011---+   
             +-gnu89----------+   
             +-gnu90----------+   
             '-gnu11----------'   

Read syntax diagramSkip visual syntax diagram
-qlanglvl syntax (C++ only)

                    .-extended---.   
>>- -q--langlvl--=--+-extended0x-+-----------------------------><
                    '-extended1y-'   

Read syntax diagramSkip visual syntax diagram
-std syntax (C++ only)

             .-gnu++98-.   
             +-gnu++03-+   
>>- -std--=--+-c++98---+---------------------------------------><
             +-c++03---+   
             +-c++11---+   
             +-gnu++11-+   
             +-c++0x---+   
             +-gnu++0x-+   
             '-c++1y---'   

Defaults

  • C only-std=gnu99 or -std=gnu9x
  • C++ only-std=gnu++98
  • C only The default is set according to the command used to invoke the compiler:
    • -qlanglvl=extc99 for the xlc and related invocation commands
    • -qlanglvl=extended for the cc and related invocation commands
    • -qlanglvl=stdc89 for the c89 and related invocation commands
    • -qlanglvl=stdc99 for the c99 and related invocation commands
  • C++ only The default is set according to the command used to invoke the compiler:
    • -qlanglvl=extended for the xlC or xlc++ and related invocation commands

Parameters for C language programs

Parameters of the -std option:
c89 | c90 | iso9899:1990
Compilation conforms strictly to the ANSI C89 standard, also known as ISO C90.
iso9899:199409
Compilation conforms strictly to the ISO C95 standard.
c99 | c9x | iso9899:1999 | iso9899:199x
Compilation conforms strictly to the ISO C99 standard, also known as ISO C99.
C11c11 | c1x | iso9899:2011
Compilation conforms strictly to the ISO C11 standard.C11
gnu89 | gnu90
Compilation conforms to the ANSI C89 standard and accepts implementation-specific language extensions, also known as GNU C90.
gnu99 | gnu9x
Compilation conforms to the ISO C99 standard and accepts implementation-specific language extensions, also known as GNU C99.
gnu11
Compilation conforms to the ISO C11 standard and accepts implementation-specific language extensions, also known as GNU C11.
If you are using some of the C11 features, you must use the -qlanglvl option.

Parameters of the -qlanglvl option:
stdc89
Compilation conforms strictly to the ANSI C89 standard, also known as ISO C90.
extc89
Compilation conforms to the ANSI C89 standard and accepts implementation-specific language extensions.
stdc99
Compilation conforms strictly to the ISO C99 standard.
extc99
Compilation conforms to the ISO C99 standard and accepts implementation-specific language extensions.
extended
Compilation is based on the ISO C89 standard, with some differences to accommodate extended language features.
C11stdc11
Compilation conforms strictly to the ISO C11 standard. C11
C11extc1x
Compilation is based on the C11 standard, invoking all the currently supported C11 features and other implementation-specific language extensions. C11

Parameters for C++ language programs

Parameters of the -std option:
gnu++98 | gnu++03
Compilation is based on the ISO C++98 standard, with some differences to accommodate extended language features.
c++98 | c++03
Compilation conforms strictly to the ISO C++98 standard.
C++11 beginsc++11 | c++0x
Compilation conforms strictly to the ISO C++11 standard.C++11 ends
C++11 beginsgnu++11 | gnu++0x
Compilation is based on the ISO C++11 standard, with some differences to accommodate extended language features.C++11 ends
C++14 beginsc++1y
Compilation is based on the C++14 standard, invoking most of the C++11 features and all the currently supported C++14 features.
Note: IBM supports selected features of C++14 standard. 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 C++14 features is complete, including the support of a new C++14 standard library, the implementation might 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 new C++14 features.
C++14 ends

Parameters of the -qlanglvl option:
extended
Compilation is based on the ISO C++98 standard, with some differences to accommodate extended language features.
C++11 begins extended0x

Compilation is based on the C++11 standard, invoking most of the C++ features and all the currently-supported C++11 features.

Note: IBM supports the majority of C++11 features, known as C++0x before its ratification. IBM will continue to develop and implement the features of this standard.
C++11 ends
C++14 beginsextended1y

Compilation is based on the C++14 standard, invoking most of the C++11 features and all the currently supported C++14 features.

Note: IBM supports selected features of C++14 standard. 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 C++14 features is complete, including the support of a new C++14 standard library, the implementation might 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 new C++14 features.
C++14 ends
The following tables reflect the mapping between the -qlanglvl and -std suboptions:
Table 1. Mapping between the -qlanglvl and -std suboptions (C only)
-qlanglvl suboption Mapping to -std suboption
stdc89 c89 | c90 | iso9899:1990
extc89 gnu89 | gnu90
stdc99 c99 | c9x | iso9899:1999 | iso9899:199x
extc99 gnu99 | gnu9x
stdc11 c11 | c1x | iso9899:2011
extc1x gnu11
Table 2. Mapping between the -qlanglvl and -std suboptions (C++ only)
-qlanglvl suboption Mapping to -std suboption
extended gnu++98 | gnu++03
extended0x gnu++11 | gnu++0x
extended1y c++1y

Predefined macros

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



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us