This section discusses the implementations of the C and C++ programming languages and the language extensions provided by XL C/C++.
XL C/C++ can foster a programming style that emphasizes portability. Syntax and semantics constitute a complete specification of a programming language, but conforming implementations of a particular language specification can differ due to language extensions.
A program that conforms strictly to its language specification will have maximum portability among different environments. In theory, a program that compiles correctly with one standards-conforming compiler and that does not use any extension or implementation-defined behavior, will compile and execute properly under all other conforming compilers, insofar as hardware differences permit. A program that correctly exploits the extensions to the language that are provided by the language implementation can improve the efficiency of its object code.
XL C/C++ is consistent with the ISO/IEC International Standard 14882:2003(E), which specifies the form and establishes the interpretation of programs written in the C++ programming language. The international standard is designed to promote the portability of C++ programs among a variety of implementations. ISO/IEC 14882:1998 was the first C++ language.
The ISO/IEC 9899:1990 International Standard (also known as C89) specifies the form and establishes the interpretation of programs written in the C programming language. This specification is designed to promote the portability of C programs among a variety of implementations. This Standard was amended and corrected by ISO/IEC 9899/COR1:1994, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2:1996. To ensure that your source code adheres strictly to the amended and corrected C89 standard, specify the -qlanglvl=stdc89 compiler option.
The ISO/IEC 9899:1999 International Standard (also known as C99) is an updated standard for programs written in the C programming language. It is designed to enhance the capability of the C language, provide clarifications to C89, and incorporate technical corrections. XL C/C++ supports many features of this language specification.
The C compiler supports all language features specified in the C99
Standard. To ensure that your source code adheres to this set of
language features, use the c99 invocation
command. Note that the Standard also specifies features in the run-time
library. These features may not be supported in the current run-time
library and operating environment. The availability of system header
files provides an indication of whether such support exists.
XL C/C++ implements all C99 language features. The following
is a table of selected major features.
ISO/IEC 9899:1999 international standard extensions to IBM C | |
C99 Feature | Related Reference |
---|---|
restrict type qualifier for pointers | The restrict Type Qualifier |
universal character names | The Unicode Standard |
predefined identifier __func__ | Predefined Identifiers |
function-like macros with variable and empty arguments | Function-Like Macros |
_Pragma unary operator | The _Pragma Operator |
variable length array | Variable Length Arrays |
static keyword in array index declaration | Arrays |
complex data type | Complex Types |
long long int and unsigned long long int types | Integer Variables |
hexadecimal floating-point constants | Hexadecimal Floating Constants |
compound literals for aggregate types | Compound Literals |
designated initializers | Initializers |
C++ style comments | Comments |
implicit function declaration not permitted | Function Declarations |
mixed declarations and code | The for Statement |
_Bool type | Simple Type Specifiers |
inline function declarations | Inline Functions |
initializers for aggregates | Initializing Arrays Using Designated Initializers |
Certain specifications in the C99 Standard are based on changes and clarifications of the C89 standard, rather than on new features of the language. XL C/C++ supports all C99 language features, including the following:
Related References
Some features of the ISO/IEC 9899:1999 International Standard (C99)
are also implemented in C++. These extensions are available under the
-qlanglvl=extended compiler option.
ISO/IEC 9899:1999 international standard extensions to IBM C++ | |
C99 Feature | Reference |
---|---|
restrict type qualifier for pointers | The restrict Type Qualifier |
universal character names | The Unicode Standard |
predefined identifier __func__ | Predefined Identifiers |
variable length array | Variable Length Arrays |
complex data type | Complex Types |
hexadecimal floating-point constants | Hexadecimal Floating Constants |
compound literals for aggregate types | Compound Literals |
function-like macros with variable and empty arguments | Function-Like Macros and Variadic Macro Extensions |
_Pragma unary operator | The _Pragma Operator |
The -qlanglvl compiler option is used to specify the supported language level, and therefore affects the way your code is compiled. You can also specify the language level implicitly by using different compiler invocation commands. In general, a valid program that compiles and runs correctly under a standard language level should continue to compile correctly and run to produce the same result with the orthogonal extensions enabled.
For example, to compile C programs so that they comply strictly with the ISO/IEC 9899:1990 International Standard (C89), you need to specify -qlanglvl=stdc89. The stdc89 suboption instructs the compiler to strictly enforce the standard, and not to allow any language extensions. (The c89 compiler invocation command specifies this language level implicitly.)
You can also use extensions to the standard language levels. Extensions that do not interfere with the standard features are called orthogonal extensions. For example, when you compile C programs, you can enable extensions that are orthogonal to C89 by specifying -qlanglvl=extc89.
Most of the language features described in the ISO/IEC 9899:1999 International Standard (C99) are considered orthogonal extensions to C89.
Non-orthogonal extensions, on the other hand, can interfere or conflict with aspects of the language as described in one of the international standards. Acceptance of these extensions must be explicitly enabled by a particular compiler option. Reliance on non-orthogonal extensions reduces the ease with which your application can be ported to different environments.
The main suboptions for the -qlanglvl option are listed
below.
Selected -qlanglvl suboptions | |
-qlanglvl Suboption | Suboption Description |
---|---|
-qlanglvl=stdc99 |
Specifies strict conformance to the C99 standard.
|
-qlanglvl=stdc89 |
Specifies strict conformance to the C89 standard.
|
-qlanglvl=extc99 |
Enables all extensions orthogonal to C99.
|
-qlanglvl=extc89 |
Enables all extensions orthogonal to C89.
|
-qlanglvl=extended |
Enables all extensions orthogonal to C89 and specifies the -qupconv compiler option.
|
Related References