Option Type | Default Value | #pragma options | C | C++ |
-qoption | langlvl=ansi* | LANGlvl=language | x | x |
Syntax
-qlanglvl=language LANGLVL=language
Purpose
Selects the C or C++ language level for the compilation.
Default
The default language level is ansi when you
invoke the compiler using the xlC, xlc,
or c89 command. The default language level is extended
when you invoke the compiler using the icc
command.
You can use either of the following preprocessor directives to specify the language level in your C or C++ source program:
#pragma options langlvl=language
#pragma langlvl(language)
The pragma directive must appear before any noncommentary lines in the source code.
Notes
For C programs, language is one of:
ansi | Compilation conforms to the ANSI C standard. |
saal2 | Compilation conforms to the SAA C Level 2 CPI language definition, with some exceptions. |
saa | Compilation conforms to the current SAA C CPI language definition. This is currently SAA C Level 2. |
EXTended | Provides compatibility with the RT compiler and classic. |
classic | Allows the compilation of non-ANSI programs, and conforms closely to the K&R level preprocessor. |
For C++ programs, language is one of:
ansi | Compilation conforms to the ANSI C standard for C programs, and the proposed ANSI working paper for C++ programs. The macro __ANSI__ is predefined to be 1. |
extended | Compilation conforms is the same as ansi mode, with some differences. Refer to Conflicts Between extended C and Other Levels for details. |
compat | Compilation is compatible with older
levels of the C++ language. Module initialization occurs
in link order. The macro __COMPAT__ is
predefinedto be 1. The effects of using this option on C++ programs are:
|
Exceptions to the ansi mode addressed by classic are as follows:
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:
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 sero. |
||||||||||||||||
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 between classic mode and ansi mode. Directives not listed here behave similarly in both modes.
|
||||||||||||||||
Macro expansion |
|
||||||||||||||||
Text Output | No text is generated to replace comments. |
List of Compiler Options and Their
Defaults
Options that Specify Compiler
Characteristics