Determines whether source code and compiler options should be checked for conformance to a specific language standard, or subset or superset of a standard.
-qlanglvl syntax — C .-:---------------------. V .-extc99------------. | >>- -q--langlvl--=----+-classic-----------+-+------------------>< +-extc1x------------+ +-extc89------------+ +-extended----------+ +-saa---------------+ +-saal2-------------+ +-stdc89------------+ +-stdc99------------+ '-feature_suboption-'
#pragma langlvl syntax — C only .-extc99---. >>-#--pragma--langlvl--(--+-classic--+--)---------------------->< +-extc1x---+ +-extc89---+ +-extended-+ +-saa------+ +-saal2----+ +-stdc89---+ '-stdc99---'
-qlanglvl syntax — C++ .-:---------------------. V .-extended----------. | >>- -q--langlvl--=----+-compat366---------+-+------------------>< +-extended0x--------+ +-strict98----------+ '-feature_suboption-'
Options | Language levels | |||
---|---|---|---|---|
compat366 | strict98 | extended (C++) | extended0x | |
-qlanglvl=anonstruct | noanonstruct | Off | Off | On | On |
-qlanglvl=anonunion | noanonunion | On | Off | On | On |
-qlanglvl=ansifor | noansifor | Off | On | On | On |
-qlanglvl=ansisinit | noansisinit | On | On | On | On |
-qlanglvl=autotypededuction| noautotypededuction | Off | Off | Off | On |
-qlanglvl=c1xnoreturn | noc1xnoreturn | Off | Off | On | On |
-qlanglvl=c99__func__ | noc99__func__ | Off | Off | On | On |
-qlanglvl=c99complex | noc99complex | Off | Off | Off | Off |
-qlanglvl=c99complexheader | noc99complexheader | Off | Off | Off | Off |
-qlanglvl=c99compoundliteral | noc99compoundliteral | Off | Off | On | On |
-qlanglvl=c99hexfloat | noc99hexfloat | Off | Off | On | On |
-qlanglvl=c99longlong | noc99longlong | Off | Off | Off | On |
-qlanglvl=c99preprocessor | noc99preprocessor | Off | Off | Off | On |
-qlanglvl=c99vla | noc99vla | Off | Off | On | On |
-qlanglvl=compatrvaluebinding | nocompatrvaluebinding | Off | Off | Off | Off |
-qlanglvl=compatzea | nocompatzea | Off | Off | Off | Off |
-qlanglvl=complexinit | nocomplexinit | Off | Off | On | On |
-qlanglvl=constexpr | noconstexpr | Off | Off | Off | On |
-qlanglvl=decltype | nodecltype | Off | Off | Off | On |
-qlanglvl=defaultanddelete | nodefaultanddelete | Off | Off | Off | On |
-qlanglvl=delegatingctors | nodelegatingctors | Off | Off | Off | On |
-qlanglvl=dependentbaselookup | nodependentbaselookup | On | On | On | Off |
-qlanglvl=emptystruct | noemptystruct | On | On | On | On |
-qlanglvl=explicitconversionoperators | noexplicitconversionoperators | Off | Off | Off | On |
-qlanglvl=extendedfriend | noextendedfriend | Off | Off | Off | On |
-qlanglvl=extendedintegersafe | noextendedintegersafe | Off | Off | Off | Off |
-qlanglvl=externtemplate | noexterntemplate | Off | Off | On | On |
-qlanglvl=FileScopeConstExternLinkage | noFileScopeConstExternLinkage | Off | Off | Off | Off |
-qlanglvl=inlinenamespace | noinlinenamespace | Off | Off | Off | On |
-qlanglvl=gnu_assert | nognu_assert | Off | Off | On | On |
-qlanglvl=gnu_complex | nognu_complex | Off | Off | Off | Off |
-qlanglvl=gnu_computedgoto | nognu_computedgoto | Off | Off | On | On |
-qlanglvl=gnu_explicitregvar | nognu_explicitregvar | Off | Off | On | On |
-qlanglvl=gnu_externtemplate | nognu_externtemplate | Off | Off | On | On |
-qlanglvl=gnu_labelvalue | nognu_labelvalue | Off | Off | On | On |
-qlanglvl=gnu_locallabel | nognu_locallabel | Off | Off | On | On |
-qlanglvl=gnu_include_next | nognu_include_next | On | On | On | On |
-qlanglvl=gnu_membernamereuse | nognu_membernamereuse | Off | Off | On | On |
-qlanglvl=gnu_suffixij | nognu_suffixij | Off | Off | On | On |
-qlanglvl=gnu_varargmacros | nognu_varargmacros | Off | Off | On | On |
-qlanglvl=gnu_warning | nognu_warning | Off | Off | On | On |
-qlanglvl=illptom | noillptom | On | Off | On | On |
-qlanglvl=implicitint | noimplicitint | On | Off | On | On |
-qlanglvl=newexcp | nonewexcp | Off | Off | Off | Off |
-qlanglvl=nullptr | nonullptr | Off | Off | Off | On |
-qlanglvl=offsetnonpod | nooffsetnonpod | On | Off | On | Off |
-qlanglvl=olddigraph | noolddigraph | Off | On | Off | Off |
-qlanglvl=oldfriend | nooldfriend | On | Off | On | Off |
-qlanglvl=oldmath | nooldmath | On | Off | Off | Off |
-qlanglvl=oldtempacc | nooldtempacc | On | Off | On | On |
-qlanglvl=oldtmplalign | nooldtmplalign | On | Off | Off | Off |
-qlanglvl=oldtmplspec | nooldtmplspec | On | Off | On | On |
-qlanglvl=redefmac | noredefmac | Off | Off | Off | Off |
-qlanglvl=referencecollapsing | noreferencecollapsing | Off | Off | Off | On |
-qlanglvl=rightanglebracket | norightanglebracket | Off | Off | Off | On |
-qlanglvl=rvaluereferences | norvaluereferences | Off | Off | Off | On |
-qlanglvl=scopedenum | noscopedenum | Off | Off | Off | On |
-qlanglvl=static_assert | nostatic_assert | Off | Off | Off | On |
-qlanglvl=tempsaslocals | notempsaslocals | Off | Off | Off | Off |
-qlanglvl=textafterendif | notextafterendif | Off | Off | Off | Off |
-qlanglvl=trailenum | notrailenum | On | Off | On | On |
-qlanglvl=typedefclass | notypedefclass | On | Off | On | On |
-qlanglvl=noucs | nonoucs | Off | Off | Off | Off |
-qlanglvl=varargmacros | novarargmacros | Off | Off | On | On |
-qlanglvl=variadic[templates] | novariadic[templates] | Off | Off | Off | On |
-qlanglvl=zeroextarray | nozeroextarray | Off | Off | On | On |
For details, see Differences between the classic language level and all other standard-based language levels.
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++.
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++.
{
//...
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++.
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.
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.
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.
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.
The default option is -qlanglvl=noc99preprocessor.
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.
If both the -qlanglvl=compatrvaluebinding and -qlanglvl=rvaluereferences options are in effect, the compiler issues an error message.
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.
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.
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.
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.
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.
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;
}
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;
}
struct S {
; // this line is ill-formed
};
The default is -qlanglvl=noemptystruct.
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.
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.
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.
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.
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. |
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.
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.
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;
The following specifiers do not completely specify a type:
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).
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;
}
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.
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.
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.
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++.
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.
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;
Specify -qlanglvl=nooldmath for strict compliance with the C++ standard. Specify -qlanglvl=oldmath for compatibility with earlier versions of VisualAge C++ and predecessor products.
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&). 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.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> { /*...*/};
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.
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.
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.
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.
For details, see Use the -qlanglvl=tempsaslocals option to extend the lifetime of C++ temporaries.
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++.
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].
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.
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.
See Macros related to language levels for a list of macros that are predefined by -qlanglvl suboptions.