-qlanglvl

Category

Language element control

Pragma equivalent

C only #pragma options langlvl, #pragma langlvl

C++ only See also #pragma operator_new

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

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

Read syntax diagramSkip visual syntax diagram
#pragma langlvl syntax — C only

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

Read syntax diagramSkip visual syntax diagram
-qlanglvl syntax — C++

                    .-:---------------------.   
                    V .-extended----------. |   
>>- -q--langlvl--=----+-compat366---------+-+------------------><
                      +-extended0x--------+     
                      +-strict98----------+     
                      '-feature_suboption-'     

Defaults

Parameters for C language programs

C only 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/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.

Parameters for C++ language programs

C++ only The following are the -qlanglvl group option parameters for corresponding C++ language levels:
compat366
Compilation conforms to some, but not all, IBM C++ Compiler V3.6 features.
strict98
Compilation conforms strictly to the ISO C++ standard.
extended
Compilation is based on the ISO C++ 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. Table 1 provides details about the supported features. For more information about C++11 features, see Extensions for C++11 compatibility
Note: IBM supports selected features of C++11, known as C++0x 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 C++11 features is complete, including the support of a new C++11 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 new C++11 features.
C++11 ends
The following are the -qlanglvl suboption parameters for individual C++ features.
feature_suboption
feature_suboption in the syntax diagram represents a colon-separated list of the remaining C++ options. They can be any of the following:
Note: When multiple -qlanglvl group options and suboptions are specified for one individual C++ feature, the last one takes effect.
anonstruct | noanonstruct
Enables or disables support for anonymous structures and classes. Anonymous structures are typically used in unions, as in the following code fragment:
union U {
   struct {
      int i:16;
      int j:16;
   };
   int k;
} u;
// ...
u.j=3;
When the default, -qlanglvl=anonstruct, is in effect, anonymous structures are supported.

This is an extension to the C++ standard and gives behavior that is designed to be compatible with Microsoft Visual C++. Specify -qlanglvl=noanonstruct for compliance with standard C++.

anonunion | noanonunion
Controls the members that are allowed in anonymous unions. When the default, -qlanglvl=anonunion, is in effect, anonymous unions can have members of all types that standard C++ allows in non-anonymous unions. For example, non-data members, such as structures, typedefs, and enumerations are allowed. Member functions, virtual functions, or objects of classes that have non-trivial default constructors, copy constructors, or destructors cannot be members of a union, regardless of the setting of this option.

This is an extension to standard C++ and gives behavior that is designed to be compatible with previous versions of VisualAge® C++ and predecessor products, and Microsoft Visual C++. Specify -qlanglvl=noanonunion for compliance with standard C++.

ansifor | noansifor
Controls whether scope rules defined in the C++ standard apply to names declared in for loop initialization statements. When the default, -qlanglvl=ansifor, is in effect, standard C++ rules are used, and the following code causes a name lookup error:
{
   //...
   for (int i=1; i<5; i++) {
      cout << i * 2 << endl;
   }
   i = 10;  // error
}
The reason for the error is that i, or any name declared within a for loop initialization statement, is visible only within the for statement. To correct the error, either declare i outside the loop or set noansifor.

When -qlanglvl=noansifor is in effect, the old language behavior is used; specify -qlanglvl=noansifor for compatibility with earlier versions of VisualAge C++ and predecessor products, and Microsoft Visual C++.

ansisinit | noansisinit
Controls whether standard C++ rules apply for handling static destructors for global and static objects. When the default, -qlanglvl=ansisinit, is in effect, the standard rules are used.

When -qlanglvl=noansisinit is in effect, the old language behavior is used; specify -qlanglvl=noansisinit for compatibility with earlier versions of VisualAge C++ and predecessor products.

C++11 autotypededuction| noautotypededuction
Controls whether the auto type deduction feature is enabled. When you specify the -qlanglvl=autotypededuction option, the auto type deduction feature is enabled, with which you no longer need to specify a type while declaring a variable. Instead, the compiler deduces the type of an auto variable from the type of its initializer expression.
You can also use the -qlanglvl=autotypededuction option to control the trailing return type feature. This feature is useful when declaring the following types of templates and functions:
  • Function templates or member functions of class templates with return types that depend on the types of the function arguments
  • Functions or member functions of classes with complicated return types
  • Perfect forwarding functions

The -qlanglvl=autotypededuction option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the auto type deduction feature.

The default option is -qlanglvl=noautotypededuction.

c1xnoreturn | noc1xnoreturn

Enables or disables support of the _Noreturn function specifier.

The -qlanglvl=c1xnoreturn option is included in group options -qlanglvl=extended and -qlanglvl=extended0x, so you can also use these group options to enable the _Noreturn function specifier.

The default option is -qlanglvl=noc1xnoreturn.

c99__func__ | noc99__func__
Enables or disables support for the C99 __func__ identifier. For details of this feature, see func_predefined identifier .
c99complex | noc99complex
Enables or disables C99 complex data types and related keywords.
c99complexheader | noc99complexheader
Enables or disables use of the C99 complex.h header file.
c99compoundliteral | noc99compoundliteral
Enables or disables support for C99 compound literals.
c99hexfloat | noc99hexfloat
Enables or disables support for C99-style hexadecimal floating constants.
C++11 c99longlong | noc99longlong
Controls whether the C99 long long feature is enabled. When you specify the -qlanglvl=c99longlong option, the C++ compiler provides the C99 long long feature, which improves source compatibility between the C and C++ languages.

The -qlanglvl=c99longlong option conflicts with the -qlonglong option. If you specify both these two options, the -qlonglong option is ignored. For more information about the -qlonglong option, see -qlonglong.

The -qlanglvl=c99longlong option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the C99 long long feature.

The default option is -qlanglvl=noc99longlong.

C++11 c99preprocessor | noc99preprocessor
Controls whether the C99 preprocessor features adopted in C++11 are enabled. When -qlanglvl=c99preprocessor is in effect, the C99 and C++11 compilers provide a more common preprocessor interface, which can ease porting C source files to the C++ compiler and avoid preprocessor compatibility issues.

The default option is -qlanglvl=noc99preprocessor.

Note: Specifying -qlanglvl=c99preprocessor implicitly sets -qlanglvl=varargmacros. Also, specifying -qlanglvl=noc99preprocessor implicitly sets -qlanglvl=novarargmacros.

The -qlanglvl=c99preprocessor option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the C99 preprocessor feature.

c99vla | noc99vla
Enables or disables support for C99-type variable length arrays.
IBM extensioncompatrvaluebinding | nocompatrvaluebinding
The C++ Standard (2003) indicates that an rvalue can only be bound to a const non-volatile lvalue reference. Non-compliant compilers might allow a non-const or volatile lvalue reference to be bound to an rvalue. When you are porting code to IBM XL C/C++ compiler, you can specify this option to instruct the compiler to allow a non-const or volatile lvalue reference to bind to an rvalue of a user-defined type where an initializer is not required.IBM extension

C++11 If both the -qlanglvl=compatrvaluebinding and -qlanglvl=rvaluereferences options are in effect, the compiler issues an error message.C++11

compatzea | nocompatzea
Controls whether zero extent arrays have an underlying dimension of 1 or 0. When the default, -qlanglvl=nocompatzea, is in effect, zero extent arrays have a dimension of 0. Use -qlanglvl=compatzea to specify that zero extent arrays have a dimension of 1, for compatibility with code compiled with VisualAge C++ V6.0 and predecessor products. Specifying -qlanglvl=compatzea has effect only if -qlanglvl=zeroextarray is also in effect.
C++ onlycomplexinit | nocomplexinit
Controls whether the C++ compiler uses the C11 style initialization of the C99 complex types.

The -qlanglvl=complexinit option is included in the group options -qlanglvl=extended and -qlanglvl=extended0x, so you can also use these group options to enable the initialization of complex types. In this case, specify -qlanglvl=c99complexheader so that correct header files can be used by the compiler.

The default option is -qlanglvl=complexinit.C++ only

C++11 constexpr | noconstexpr
Controls whether the generalized constant expressions feature is enabled. When you specify the -qlanglvl=constexpr option, the compiler extends the expressions permitted within constant expressions. A constant expression is an expression that can be evaluated at compile time.

The -qlanglvl=constexpr option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the generalized constant expressions feature.

The default option is -qlanglvl=noconstexpr.

C++11 decltype | nodecltype
Controls whether the decltype feature is enabled. With this feature, you can get a type that is based on the resultant type of a possibly type-dependent expression. To enable this feature, you can specify the -qlanglvl=decltype option.

The -qlanglvl=decltype option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the decltype feature.

The default option is -qlanglvl=nodecltype.

C++11 defaultanddelete | nodefaultanddelete
Controls whether the defaulted and deleted functions feature is enabled. With this feature, you can define explicitly defaulted functions whose implementations are generated by the compiler to achieve higher efficiency. You can also define deleted functions whose usages are disabled by the compiler to avoid calling unwanted functions. To enable this feature, you can specify the -qlanglvl=defaultanddelete option.

The -qlanglvl=defaultanddelete option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable this feature.

The default option is -qlanglvl=nodefaultanddelete.

C++11 delegatingctors | nodelegatingctors
Controls whether the delegating constructors feature is enabled. With this feature, you can concentrate on common initializations and post initializations in one constructor, which can make programs more readable and maintainable. To enable this feature, you can specify the -qlanglvl=delegatingctors option.

The -qlanglvl=delegatingctors option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the delegating constructors feature.

The default option is -qlanglvl=nodelegatingctors.

DependentBaseLookup | noDependentBaseLookup
Controls whether the name lookup rules for a template base class of dependent type defined in the Technical Corrigendum 1 (TC1) of the C++ Standard apply. Specify -qlanglvl=noDependentBaseLookup for compliance with TC1. When -qlanglvl=noDependentBaseLookup is in effect, unqualified names in a template class will not be resolved in a base class if that base class is dependent on a template parameter. These names must be qualified with the base class name in order to be found by name lookup. When the default, -qlanglvl=DependentBaseLookup, is in effect, the behavior of previous XL C++ compilers remains.
Note: The default option is -qlanglvl=noDependentBaseLookup at the C++11 language level.
The following example shows code that does not compile with -qlanglvl=noDependentBaseLookup:
struct base 
{
          int baseName;
};

template <class B> struct derived : public B
{    
   void func()
    {
    int i = baseName;     // this name will not be found in the base class
    }; 
};

int main(void)
{    
   derived<base> x;
   x.func();    
   return 0;
}
The following example shows code that compiles with or without -qlanglvl=nodependentbaselookup:
struct base 
{
          int baseName;
};

template <class B> struct derived : public B
{    
   void func()
    {
    int i = B::baseName;   // qualified name will be found in the base class
    }; 
};

int main(void)
{    
   derived<base> x;
   x.func();    
   return 0;
}
empty_struct | noempty_struct
This option instructs the compiler to tolerate empty member declarations in structs. Empty member declaration in structs is not allowed. For example, when -qlanglvl=noemptystruct is in effect, the following example will be rejected by the compiler:
struct S {
      ;  // this line is ill-formed
};

The default is -qlanglvl=noemptystruct.

C++11 explicitconversionoperators | noexplicitconversionoperators
Controls whether the explicit conversion operators feature is enabled. When you specify the -qlanglvl=explicitconversionoperators option, you can apply the explicit function specifier to the definition of a user-defined conversion function, and thus inhibit unintended implicit conversions through the user-defined conversion function.

The -qlanglvl=explicitconversionoperators option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the explicit conversion operators feature.

The default option is -qlanglvl=noexplicitconversionoperators.

C++11 extendedfriend | noextendedfriend
Controls whether the extended friend declarations feature is enabled. When you specify the -qlanglvl=extendedfriend option, rules governing friend declarations are relaxed as follows:
  • Template parameters, typedef names, and basic types can be declared as friends.
  • The class-key in the context for friend declarations is no longer necessary in C++11.

The -qlanglvl=extendedfriend option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the extended friend declarations feature.

The default option is -qlanglvl=noextendedfriend.

Note: -qlanglvl=extendedfriend is incompatible with the -qlanglvl=oldfriend option. When -qlanglvl=extendedfriend is in effect, the -qlanglvl=oldfriend option is ignored and the setting of -qlanglvl=[no]oldfriend is -qlanglvl=nooldfriend.
C++11 IBM extension extendedintegersafe | noextendedintegersafe
With this option, if a decimal integer literal that does not have a suffix containing u or U cannot be represented by the long long int type, you can decide whether to use the unsigned long long int type to represent the literal or not.

This option takes effect only when the -qlanglvl=c99longlong option is specified, otherwise, the compiler issues a warning message to indicate that the option is ignored. When you specify both the -qlanglvl=c99longlong and -qlanglvl=extendedintegersafe options, if a decimal integer literal that does not have a suffix containing u or U cannot be represented by the long long int type, the compiler issues an error message stating that the value of the literal is out of range.

The default option is -qlanglvl=noextendedintegersafe in all the language levels.

C++11 externtemplate | noexterntemplate
Controls whether the explicit instantiation declarations feature is enabled. With this feature, you can suppress the implicit instantiations of a template specialization or its members. To enable this feature, you can specify the -qlanglvl=externtemplate option, which is the default option.

The -qlanglvl=externtemplate option is included in the group options of -qlanglvl=extended and -qlanglvl=extended0x, so you can use these two group options to enable this feature.

The following table lists options that interact with the -qlanglvl=externtemplate option:
Table 2. Options that interact with -qlanglvl=externtemplate
Option Description
-qtemplateregistry, -qtempinc Explicit instantiation declarations remain effective. Referenced specializations that are the subjects of explicit instantiation declarations, but not the subjects of explicit instantiation definitions in a translation unit are not instantiated from or because of that translation unit.
The following table lists IBM language extensions that interact with the -qlanglvl=externtemplate option:
Table 3. IBM language extensions that interact with -qlanglvl=externtemplate
IBM language extension Description
#pragma instantiate This pragma is semantically the same as an explicit instantiation definition.
#pragma do_not_instantiate This pragma provides a subset of the functionality of the explicit instantiation declarations which is introduced in the C++11 standard. It is provided for backwards compatibility purposes only. New applications can use explicit instantiation declarations.
#pragma hashome, #pragma ishome This pragma causes the generation of the virtual function table (VFT) for a class template specialization irrespective of explicit instantiation declarations of the specialization.

The -qlanglvl=[no]externtemplate option replaces the deprecated -qlanglvl=[no]gnu_externtemplate option. Use the -qlanglvl=[no]externtemplate option in your applications.

FileScopeConstExternLinkage | noFileScopeConstExternLinkage
Controls whether the file scope of constant variables has internal or external linkage when the static or extern keyword is not specified.

When -qlanglvl=FileScopeConstExternLinkage is in effect, all file scope constant variables are marked as externally visible. Otherwise, all file scope constant variables are marked as static.

The default is -qlanglvl=noFileScopeConstExternLinkage.

gnu_assert | nognu_assert
Enables or disables support for the following GNU C system identification assertions:
  • #assert
  • #unassert
  • #cpu
  • #machine
  • #system
gnu_complex | nognu_complex
Enables or disables GNU complex data types and related keywords.
gnu_computedgoto | nognu_computedgoto
Enables or disables support for computed goto statements.
gnu_externtemplate | nognu_externtemplate
Enables or disables extern template instantiations. For details of this feature, see Explicit instantiation .
Note: The option -qlanglvl=[no]gnu_externtemplate is deprecated in XL C/C++ V13.1; you can use the option -qlanglvl=[no]externtemplate instead.
gnu_include_next | nognu_include_next
Enables or disables support for the GNU C #include_next preprocessor directive.
gnu_labelvalue | nognu_labelvalue
Enables or disables support for labels as values.
gnu_locallabel | nognu_locallabel
Enables or disables support for locally-declared labels.
gnu_membernamereuse | nognu_membernamereuse
Enables or disables reusing a template name in a member list as a typedef.
gnu_suffixij | nognu_suffixij
Enables or disables support for GNU-style complex numbers. When -qlanglvl=gnu_suffixij is in effect, a complex number can be ended with suffix i/I or j/J.
gnu_varargmacros | nognu_varargmacros
Enables or disables support for GNU-style macros with variable arguments.
For details of this feature, see Variadic macro extensions .
gnu_warning | nognu_warning
Enables or disables support for the GNU C #warning preprocessor directive.
illptom | noillptom
Controls the expressions that can be used to form pointers to members. When the default, -qlanglvl=illptom, is in effect, the XL C++ compiler accepts some forms that are in common use but do not conform to the C++ Standard. For example, the following code defines a pointer to a function member, p, and initializes it to the address of C::func, in the old style:
struct C {
void func(int);
};

void (C::*p) (int) = C::func;

This is an extension to standard C++ and gives behavior that is designed to be compatible with earlier versions of VisualAge C++ and its predecessor products, and Microsoft Visual C++.

Specify -qlanglvl=noillptom for compliance with the C++ standard. The example code above must be modified to use the & operator.

struct C {
void func(int);
};

void (C::*p) (int) = &C::func;
implicitint | noimplicitint
Controls whether the compiler accepts missing or partially specified types as implicitly specifying int. When the default, -qlanglvl=implicitint, is in effect, a function declaration at namespace scope or in a member list will implicitly be declared to return int. Also, any declaration specifier sequence that does not completely specify a type will implicitly specify an integer type. The effect is as if the int specifier were present.

The following specifiers do not completely specify a type:

  • auto
  • const
  • extern
  • extern “literal
  • inline
  • mutable
  • friend
  • register
  • static
  • typedef
  • virtual
  • volatile
  • platform-specific types

C++11 begins C++11 has removed the use of auto as a storage class specifier. In C++11, the keyword auto is used as a type specifier. The compiler deduces the type of an auto variable from the type of its initializer expression. For more information, see The auto type specifier (C++11). C++11 ends

For example, the return type of function MyFunction is int because it was omitted in the following code:

MyFunction()
{
   return 0;
}

Note that any situation where a type is specified is affected by this suboption. This includes, for example, template and parameter types, exception specifications, types in expressions (eg, casts, dynamic_cast, new), and types for conversion functions.

This is an extension to the C++ standard and gives behavior that is designed to be compatible with earlier versions of VisualAge C++ and predecessor products, and Microsoft Visual C++.

Specify -qlanglvl=noimplicitint for compliance with standard C++. For example, the function declaration above must be modified to:

int MyFunction()
{
   return 0;
}
C++11 only inlinenamespace | noinlinenamespace
Controls whether inline namespace definitions are enabled, which are namespace definitions preceded by an initial inline keyword. A namespace so defined is an inline namespace. When you specify the -qlanglvl=inlinenamespace option, members of the inline namespace can be defined and specialized as if they were also members of the enclosing namespace.

The -qlanglvl=inlinenamespace option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the inline namespace definitions feature.

The default option is -qlanglvl=noinlinenamespace.

newexcp | nonewexcp
Controls whether the new operator throws an exception when the requested memory fails. When the default, -qlanglvl=nonewexcp, is in effect, the null pointer 0 is returned. When -qlanglvl=newexcp is in effect, the standard exception std::bad_alloc is thrown. For compatibility with earlier versions of VisualAge C++ and predecessor products, specify -qlanglvl=nonewexcp. For conformance to the C++ standard, which fully supports new exceptions, specify -qlanglvl=newexcp.

This suboption does not apply to the nothrow versions of the new operator, new operators with empty throw specifications, class-specific new operators, and new operators with placement arguments.

Note: You can also use the equivalent #pragma operator_new directive to specify this suboption for selected portions of code. See #pragma operator_new (C++ only) for details.
C++11 only nullptr | nonullptr
Controls whether the nullptr feature is enabled. A null pointer with the nullptr value can be converted to any pointer type, pointer-to-member type, or bool type. The nullptr constant can be distinguished from the integer 0 for overloaded functions.

The -qlanglvl=nullptr option is included in the group option -qlanglvl=extended0x; you can also use this group option to enable the nullptr keyword feature.

The default option is -qlanglvl=nonullptr.

offsetnonpod | nooffsetnonpod
Controls whether the offsetof macro can be applied to classes that are not data-only. C++ programmers often casually call data-only classes “Plain Old Data” (POD) classes. When the default, -qlanglvl=offsetnonpod, is in effect, you can apply offsetof to a class that contains one of the following:
  • Implicitly declared or C++11 beginsexplicitly defaultedC++11 ends constructors or destructors
  • Iimplicitly declared or C++11 beginsexplicitly defaultedC++11 ends assignment operators
  • private or protected non-static data members
  • base classes
  • virtual functions
  • non-static data members of type pointer to member
  • a struct or union that has non-data members
  • references

This is an extension to the C++ standard, and gives behavior that is designed to be compatible with VisualAge C++ for OS/2 3.0, VisualAge for C++ for Windows, V3.5, and Microsoft Visual C++. Specify -qlanglvl=nooffsetnonpod for compliance with standard C++.

olddigraph | noolddigraph
Enables or disables support for old-style digraphs. When the default, -qlanglvl=olddigraph, is in effect, old-style digraphs are not supported. When -qlanglvl=olddigraph is in effect, the following digraphs are supported:
Digraph
Resulting character
%%
# (pound sign)
%%%%
## (double pound sign, used as the preprocessor macro concatenation operator)

Specify -qlanglvl=noolddigraph for compatibility with standard C++ and the extended C++ language level supported by previous versions of VisualAge C++ and predecessor products.

This suboption only has effect when -qdigraphs is in effect.

oldfriend | nooldfriend
Controls whether friend declarations that name classes without elaborated class names are treated as C++ errors. When the default, -qlanglvl=oldfriend, is in effect, you can declare a friend class without elaborating the name of the class with the keyword class. For example, the statement below declares the class IFont to be a friend class:
friend IFont;

This is an extension to the C++ standard and gives behavior that is designed to be compatible with earlier versions of VisualAge C++ and predecessor products, and Microsoft Visual C++.

Specify the -qlanglvl=nooldfriend for compliance with standard C++. The example declaration above must be modified to the following:

friend class IFont;
Note: -qlanglvl=oldfriend is incompatible with the -qlanglvl=extendedfriend option. When -qlanglvl=extendedfriend is in effect, the -qlanglvl=oldfriend option is ignored and the setting of -qlanglvl=[no]oldfriend is -qlanglvl=nooldfriend.
oldmath | nooldmath
Controls the versions of math function declarations in math.h that are included when you specify math.h as an included or primary source file.

Specify -qlanglvl=nooldmath for strict compliance with the C++ standard. Specify -qlanglvl=oldmath for compatibility with earlier versions of VisualAge C++ and predecessor products.

oldtempacc | nooldtempacc
Controls whether access to a copy constructor to create a temporary object is always checked, even if creation of the temporary object is avoided. When the default, -qlanglvl=oldtempacc, is in effect, access checking is suppressed.
This is an extension to the C++ standard and gives behavior that is designed to be compatible with VisualAge C++ for OS/2 3.0, VisualAge for C++ for Windows, V3.5, and Microsoft Visual C++. Specify -qlanglvl=nooldtempacc for compliance with standard C++. For example, the throw statement in the following code causes an error because the copy constructor is a protected member of class C:
class C {
public:
   C(char *);
protected:
   C(const C&);
};

C func() {return C(“test”);} // return copy of C object 
void f()
{
// catch and throw both make implicit copies of
// the throw object
   throw C(“error”);    // throw a copy of a C object
   const C& r = func(); // use the copy of a C object 
//                              created by func()
}
The example code above contains three ill formed uses of the copy constructor C(const C&).
oldtmplalign | nooldtmplalign
Controls whether alignment rules specified for nested templates are ignored. When the default, -qlanglvl=nooldtmplalign, is in effect, these alignment rules are not ignored. For example, given the following template the size of A<char>::B will be 5 with -qlanglvl=nooldtmplalign, and 8 with -qlanglvl=oldtmplalign :
template <class T>
struct A {
#pragma options align=packed
 struct B {
  T m;
  int m2;
 };
#pragma options align=reset
};
Specify -qlanglvl=oldtmplalign for compatibility with VisualAge for C++ V4.0 and predecessor products.
oldtmplspec | nooldtmplspec
Controls whether template specializations that do not conform to the C++ standard are allowed. When the default, -qlanglvl=oldtmplspec, is in effect, you can explicitly specialize a template class as in the following example, which specializes the template class ribbon for type char:
template<class T> class ribbon { /*...*/};
class ribbon<char> { /*...*/};
This is an extension to standard C++ and gives behavior that is designed to be compatible with VisualAge C++ for OS/2 3.0, VisualAge for C++ for Windows, V3.5, and Microsoft Visual C++.

Specify -qlanglvl=nooldtmplspec for compliance with standard C++. In the example above, the template specialization must be modified to:

template<class T> class ribbon { /*...*/};
template<> class ribbon<char> { /*...*/};
redefmac | noredefmac
Controls whether a macro can be redefined without a prior #undef or undefine() statement.
C++11 referencecollapsing | noreferencecollapsing
Controls whether the reference collapsing feature is enabled. To enable this feature, specify the -qlanglvl=referencecollapsing option.

The -qlanglvl=referencecollapsing option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the reference collapsing feature.

When the -qlanglvl=rvaluereferences option is in effect, but the -qlanglvl=referencecollapsing option is not in effect, the compiler behaves as if the -qlanglvl=referencecollapsing option were specified.

The default option is -qlanglvl=noreferencecollapsing.

C++11 rightanglebracket | norightanglebracket
Controls whether the right angle bracket feature is enabled. To enable this feature, you can specify the -qlanglvl=rightanglebracket option.

The -qlanglvl=rightanglebracket option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the right angle bracket feature.

The default option is -qlanglvl=norightanglebracket.

C++11 rvaluereferences | norvaluereferences
Controls whether the rvalue references feature is enabled. To enable this feature, specify the -qlanglvl=rvaluereferences option.

The -qlanglvl=rvaluereferences option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the rvalue references feature.

If both the -qlanglvl=compatrvaluebinding and -qlanglvl=rvaluereferences options are in effect, the compiler issues an error message.

The default option is -qlanglvl=norvaluereferences.

C++11 scopedenum | noscopedenum
Controls whether the scoped enumeration feature is enabled. To enable this feature, you can specify the -qlanglvl=scopedenum option.

The -qlanglvl=scopedenum option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the scoped enumeration feature.

The default option is -qlanglvl=noscopedenum.

C++11 only static_assert | nostatic_assert
Controls whether the static assertions feature is enabled. When -qlanglvl=static_assert is in effect, this feature can be used to produce compile-time assertions for which a severe error message is issued on failure.
-qlanglvl=static_assert is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the static assertions feature.
The default is -qlanglvl=nostatic_assert.
IBM extensiontempsaslocals | notempsaslocals
The C++ Language Standard describes the lifetime of temporaries in section Temporary Object [class.temporary]. When you are porting an application from a compiler that implements late temporary destruction, you might need to extend the lifetime of C++ temporaries beyond which is specified in the C++ Language Standard. This option extends the lifetime of temporaries to reduce migration difficulty.

For details, see Use the -qlanglvl=tempsaslocals option to extend the lifetime of C++ temporaries.

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 IBM XL C/C++ compiler. The default option is -qlanglvl=notextafterendif, indicating that a message is emitted if #else or #endif is followed by any extraneous text.
trailenum | notrailenum
Controls whether trailing commas are allowed in enum declarations. When the default, -qlanglvl=trailenum, is in effect, one or more trailing commas are allowed at the end of the enumerator list. For example, the following enum declaration uses this extension:
enum grain { wheat, barley, rye,, };

This is an extension to the C++ standard, and is intended to provide compatibility with Microsoft Visual C++.

Specify -qlanglvl=notrailenum for compliance with standard C++.

typedefclass | notypedefclass
Controls whether a typedef name can be specified where a class name is expected. When the default, -qlanglvl=typedefclass, is in effect, the standard C++ rule applies, and a typedef name cannot be specified where a class name is expected. Specify -qlanglvl=typedefclass to allow the use of typedef names in base specifiers and constructor initializer lists, for compatibility with earlier versions of VisualAge for C++ and predecessor products.
ucs | noucs
Controls whether Unicode characters are allowed in identifiers, string literals and character literals in program source code. For details on the Unicode character set, see The Unicode standard .
varargmacros | novarargmacros
Enables or disables support for C99-style variable argument lists in function-like macros.
Note: Specifying -qlanglvl=c99preprocessor implicitly set -qlanglvl=varargmacros. Vice versa, specifying -qlanglvl=noc99preprocessor implicitly set -qlanglvl=novarargmacros.
For details of this feature, see Function-like macros .
C++11 variadic[templates] | novariadic[templates]
Controls whether the variadic templates feature is enabled. With this feature, you can define class and function templates that have any number (including zero) of parameters. To enable this feature, you can specify the -qlanglvl=variadic[templates] option. The word templates included in the brackets is optional. If you specify only the -qlanglvl=variadic option, the compiler assumes that the -qlanglvl=variadictemplates option is specified.

The -qlanglvl=variadic[templates] option is included in the group option -qlanglvl=extended0x, so you can also use this group option to enable the variadic templates feature.

The default option is -qlanglvl=novariadic[templates].

zeroextarray | nozeroextarray
Controls whether you can use zero-extent arrays as the last nonstatic data member in a structure definition. When the default, -qlanglvl=zeroextarray, is in effect, you can use arrays with zero elements. The following statement declares a zero-extent array a.
struct S1 { char a[0]; };

This is an extension to the C++ standard, and is intended to provide compatibility with Microsoft Visual C++.

Specify -qlanglvl=nozeroextarray for compliance with standard C++ or with the ANSI language level supported by previous versions of VisualAge C++ and predecessor products.

Usage

C++ only In general, if you specify a suboption with the no form of the option, the compiler will diagnose any uses of the feature in your code with a warning, unless you disable the warning with the -qsuppress option. Additionally, you can use the -qinfo=por option to generate informational messages along with the following suboptions:
  • [no]c99complex
  • [no]gnu_complex
Note: C++11 beginsIn the C++11 language level, if you use the no form of a suboption to disable the C++11 meaning of decltype or static_assert, the compiler emits syntax errors but no diagnostic message if the user happens to use the C++11 syntax of decltype or static_assert.
C++11 ends

C only begins 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.C only ends

Predefined macros

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

Related information