Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Overview of the C++ language modes

&pagelevel(3)&pagelevel

In accordance with the different language definitions for C++, the compiler supports seven C++ compilation modes:

Cfront C++ mode (POSIX option -X V2-COMPATIBLE. SDF option MODE=*V2-COMPATIBLE)

The compiler accepts C++ code compatible with Cfront V3.0.3.

extended C++ V3 mode (POSIX option -X V3-COMPATIBLE -X nostrict, SDF option MODE=*V3-COMPATIBLE,STRICT=*NO) 

The compiler accepts C ++ code similar to the C/C++ V3 compiler in extended mode.

strict C++ V3 mode (POSIX option -X V3-COMPATIBLE -X strict, SDF option MODE=*V3-COMPATIBLE,STRICT=*YES) 

The compiler accepts C ++ code similar to the C/C++ V3 compiler in strict mode.

extended C++ 2017 mode (POSIX option -X 2017 -X nostrict, SDF option MODE=*2017,STRICT=*NO) 

The compiler accepts C ++ code in accordance with the 2017 C++ standard in extended mode.

strict C++ 2017 mode (POSIX option -X 2017 -X strict, SDF option MODE=*2017,STRICT=*YES) 

The compiler accepts C ++ code in accordance with the 2017 C++ standard in strict mode.

extended C++ 2020 mode (POSIX option -X 2020 -X nostrict, SDF option MODE=*2020,STRICT=*NO) 

The compiler accepts C ++ code in accordance with the 2020 C++ standard in extended mode.

strict C++ 2020 mode (POSIX option -X 2020 -X strict, SDF option MODE=*2020,STRICT=*YES) 

The compiler accepts C ++ code in accordance with the 2020 C++ standard in strict mode.

The following table contains an overview of the main differences between the various C++ language modes.

Features / Language attributes

Cfront C++

C++ V3

C++ 2017

C++ 2020

Reserved keywords 1)

overload

yes

no

no

no

Exception handling
catch, throw, try

no 2)

yes

yes

yes

Templates

template

no 2)

yes

yes

yes

Language features from C++ 1998

Runtime type information (RTTI)
typeid, dynamic_cast

no 3)

yes

yes

yes

Arrays: new/delete

new[], delete[]

noyes

yes

yes

Name space

namespace, using

no

yes

yes

yes

Template parameter typename

no

yes

yes

yes

Constructor type explicit

no

yes

yes

yes

Data type wchar_t

no

yes 4)

yes

yes

Data type bool

no

yes 5)

yes

yes

Storage class mutable

yes

yes

yes

yes

Casting keywords

const_cast, reinterpret_cast,  static_cast

yes

yes

yes

yes

export 6)

no

no

yes

no

extern inline functions

no

no

yes

yes

Symbol search in the namespaces of an argument class (Koenig-Lookup)

no

no

yes

yes

Language features from C++ 2017

Alignment control

alignas, alignof

nonoyesyes
Semantic of autostorage classstorage class typetype

Unicode support:

literals u"x", U"x", u8"x", u'x', U'x', u8'x',

char16_t, char32_t

nonoyesyes

Computation at compile time

constexpr

nonoyesyes
decltypenonoyesyes

long long

yes

yes

yes

yes

noexcept 7) nonoyesyes
nullptrnonoyesyes
register (was banned in C++17)yesyesnono
static_assertnonoyesyes
thread_localnonoyes 8) yes 8)
Trigraph (i,e,. ??<)yesyesnono

Language features from C++ 2020

char8_t

nononoyes

extended computation at compile time

consteval, constinit

nononoyes
operator <=>nononoyes
concept, requiresnononoyes

Co-routines co_await, co_return, co_yield

nononono 9)
Modulesnononoyes 10)
predefined preprocessor names

__STDC_VERSION__

==199409L

==199409L

==199409L

==199409L

__cplusplus

==1

==2 (extended)

==199612L (strict)

==201703L

==202002L

Overview of differences between the various C++ language modes

1) Reserved keywords

All keywords listed in chapter “C language support of the compiler” (Overview of the C language modes ), except restrict, are also reserved in the C++ language modes. In addition there are the following C++-specific keywords. Bold keywords are not reserved in all C++ language modes (see table above).

alignas

concept

delete

new

requires

typeid

alignof

const_cast

dynamic_cast

noexcept

static_assert

typename

asm

consteval

explicit

nullptr

static_cast

using

bool

constexpr

export

operator

template

virtual

catch

constinit

false

overload

this

wchar_t

char8_t

co_await

friend

private

thread_local


char16_t

co_return

inline

protected

throw


char32_t

co_yield

mutable

public

true


class

decltype

namespace

reinterpret_cast

try


Reservierte names in C++

The following keywords may be used as alternative tokens for C operators. They may or may not be reserved, depending on the settings of the -K alternative_token, -K no_alternative_token or ALTERNATIVE-TOKENS=*YES/*NO options.
By default, they are “not reserved” in the Cfront C++ mode and “reserved” in the modes C++ V3, C++ 2017 and C++ 2020.

and

&&

not_eq

!=

and_eq

&=

or

||

bitand

&

or_eq

|=

bitor

|

xor

^

compl

~

xor_eq

^=

not

!



Keyword operators in C++


2) Exception handling, Templates

Exception handling and templates are not supported in the Cfront-C++ mode. Howerver, the keywords catch, throw, try und template are not freely available and lead to an error message when used.

3) Runtime type information (RTTI)

In the Cfront-C++ mode the keyword dynamic_cast is active. It is checked whether the operation addressed in this way requires real runtime information or whether it can be done using the static type information. If the static information is sufficient, the appropriate code is generated. If dynamic information is required, an error message is issued.

4) Data type wchar_t

In the mode C++ V3 modes the keyword wchar_t is reserved depending on the options -K wchar_t_keyword, -K no_wchar_t_keyword resp. KEYWORD-WCHAR=*YES/*NO . -K wchar_t_keyword resp. KEYWORD-WCHAR=*YES is the default.

5) Data type bool

In the C++ V3 modes the keywords bool, true und false are reserved depending on the options -K bool, -K no_bool bzw. KEYWORD-BOOL=*YES/*NO. -K bool resp. KEYWORD-BOOL=*YES is the default.

 6) export

The use of the word export leads to a message in all C++ modes. It is an error in C++ 2017, a warning in C++ V2 and in C++ V3. In C++ 2020 mode the keyword is part of the module10) syntax. The semantics behind the keyword is not offered by the C/C++ compiler.

 7) noexcept: exception handling as part of a type

In C++ it is possible to specify for a function whether it throws exceptions or not. As of C++ 2017, only the specification yes/no is allowed, and this specification is part of the type of the function. Previously, a list of types that could be thrown could be specified. This list was checked dynamically and was not part of the type of function.

  8) thread_local

The standard C++ 2017 defines thread_local as a keyword. It can be used in the context of threads. Since the C/C++ compiler does not support thread implementation, the keyword is recognized as such and rejected with an error message.

 9) co-routines

The feature co-routines is not implemented in the current compiler. Use of the keywords will give a warning. A used keyword will then be interpreted as an identifier.

 10) Modules

The feature modules is not implemented in the current compiler. The syntax for modules is recognized and rejected with an error message.