-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---.  .-ucs---. |   
>>- -q--langlvl--=----+-classic--+--+-noucs-+-+----------------><
                      +-extc89---+                
                      +-extended-+                
                      +-saa------+                
                      +-saal2----+                
                      +-stdc89---+                
                      '-stdc99---'                

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

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

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

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

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.

The following outlines the differences between the classic language level and all other standard-based language levels:

Tokenization
Tokens introduced by macro expansion may be combined with adjacent tokens in some cases. Historically, this was an artifact of the text-based implementations of older preprocessors, and because, in older implementations, the preprocessor was a separate program whose output was passed on to the compiler.

For similar reasons, tokens separated only by a comment may also be combined to form a single token. Here is a summary of how tokenization of a program compiled in classic mode is performed:

  1. At a given point in the source file, the next token is the longest sequence of characters that can possibly form a token. For example, i+++++j is tokenized as i ++ ++ + j even though i ++ + ++ j may have resulted in a correct program.
  2. If the token formed is an identifier and a macro name, the macro is replaced by the text of the tokens specified on its #define directive. Each parameter is replaced by the text of the corresponding argument. Comments are removed from both the arguments and the macro text.
  3. Scanning is resumed at the first step from the point at which the macro was replaced, as if it were part of the original program.
  4. When the entire program has been preprocessed, the result is scanned again by the compiler as in the first step. The second and third steps do not apply here since there will be no macros to replace. Constructs generated by the first three steps that resemble preprocessing directives are not processed as such.

It is in the third and fourth steps that the text of adjacent but previously separate tokens may be combined to form new tokens.

The \ character for line continuation is accepted only in string and character literals and on preprocessing directives.

Constructs such as:

#if 0
  “unterminated
#endif
#define US ”Unterminating string
char *s = US terminated now“

will not generate diagnostic messages, since the first is an unterminated literal in a FALSE block, and the second is completed after macro expansion. However:

char *s = US;

will generate a diagnostic message since the string literal in US is not completed before the end of the line.

Empty character literals are allowed. The value of the literal is zero.

Preprocessing directives
The # token must appear in the first column of the line. The token immediately following # is available for macro expansion. The line can be continued with \ only if the name of the directive and, in the following example, the ( has been seen:
#define f(a,b) a+b
f\
(1,2)      /* accepted */
#define f(a,b) a+b
f(\
1,2)       /* not accepted */

The rules concerning \ apply whether or not the directive is valid. For example,

#\
define M 1   /* not allowed */
#def\
ine M 1      /* not allowed */
#define\
M 1          /* allowed */
#dfine\
M 1          /* equivalent to #dfine M 1, even
                   though #dfine is not valid  */

Following are the preprocessor directive differences.

#ifdef/#ifndef
When the first token is not an identifier, no diagnostic message is generated, and the condition is FALSE.
#else
When there are extra tokens, no diagnostic message is generated.
#endif
When there are extra tokens, no diagnostic message is generated.
#include
The < and > are separate tokens. The header is formed by combining the spelling of the < and > with the tokens between them. Therefore /* and // are recognized as comments (and are always stripped), and the and ' do begin literals within the < and >. (Remember that in C programs, C++-style comments // are recognized when -qcpluscmt is specified.)
#line
The spelling of all tokens which are not part of the line number form the new file name. These tokens need not be string literals.
#error
Not recognized.
#define
A valid macro parameter list consists of zero or more identifiers each separated by commas. The commas are ignored and the parameter list is constructed as if they were not specified. The parameter names need not be unique. If there is a conflict, the last name specified is recognized.

For an invalid parameter list, a warning is issued. If a macro name is redefined with a new definition, a warning will be issued and the new definition used.

#undef
When there are extra tokens, no diagnostic message is generated.
Macro expansion
  • When the number of arguments on a macro invocation does not match the number of parameters, a warning is issued.
  • If the ( token is present after the macro name of a function-like macro, it is treated as too few arguments (as above) and a warning is issued.
  • Parameters are replaced in string literals and character literals.
  • Examples:
    #define M()    1
    #define N(a)   (a)
    #define O(a,b) ((a) + (b))
    M();  /* no error */
    N();  /* empty argument */
    O();  /* empty first argument 
                and too few arguments */
Text output
No text is generated to replace comments.
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.
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++0x extended0x
Compilation is based on the C++0x standard, invoking all the C++ and currently-supported C++0x features that are implemented in this release. For more information about these C++0x features, see Extensions for C++0x compatibility
Note: C++0x is a new version of the C++ programming language standard. This is a draft standard and has not been officially adopted in its entirety. Note that future levels of support for this standard are likely to change. The implementation of the language level is based on IBM's interpretation of the draft C++0x standard, and is subject to change at any time without notice. IBM makes no attempt to maintain compatibility with earlier releases, in source or binary, of the new C++0x -qlanglvl suboptions (their names or their semantics) and therefore they should not be relied on as a stable programming interface.
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++0x 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.

The -qlanglvl=autotypededuction option is included in the group option -qlanglvl=extended0x.

The default option is -qlanglvl=noautotypededuction.

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++0x 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++0x c99preprocessor | noc99preprocessor
Controls whether the C99 preprocessor features adopted in C++0x are enabled. When -qlanglvl=c99preprocessor is in effect, the C99 and C++0x 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.
c99vla | noc99vla
Enables or disables support for C99-type variable length arrays.
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 should 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++0x 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++0x delegatingctors | nodelegatingctors
Controls whether the delegating constructors feature is enabled. With this feature, you can concentrate 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.
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++0x 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++0x.

The -qlanglvl=extendedfriend option is included in the group option -qlanglvl=extended0x.

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++0x 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++0x 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++0x 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 have 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++ V11.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::foo, in the old style:
struct C {
void foo(int);
};

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

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 foo(int);
};

void (C::*p) (int) = &C::foo;
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++0x C++0x has removed the use of auto as a storage class specifier. In C++0x, 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++0x).

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++0x 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.

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.
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:
  • user-declared constructors or destructors
  • user-declared 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 foo() {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 = foo(); // use the copy of a C object 
//                              created by foo()
}
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++0x 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.
The default is -qlanglvl=nostatic_assert.
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++0x 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 zero-extent arrays are allowed as the last non-static data member in a class definition. When the default, -qlanglvl=zeroextarray, is in effect, arrays with zero elements are allowed. The example declarations below define dimensionless arrays a and b.
struct S1 { char a[0]; };
struct S2 { char b[]; };

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

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