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) | ||||
| yes | no | no | no |
Exception handling | no 2) | yes | yes | yes |
Templates
| no 2) | yes | yes | yes |
Language features from C++ 1998 | ||||
Runtime type information (RTTI) | no 3) | yes | yes | yes |
Arrays: new/delete
| no | yes | yes | yes |
Name space
| no | yes | yes | yes |
Template parameter | no | yes | yes | yes |
Constructor type | no | yes | yes | yes |
Data type | no | yes 4) | yes | yes |
Data type | no | yes 5) | yes | yes |
Storage class | yes | yes | yes | yes |
Casting keywords
| yes | yes | yes | yes |
| no | no | yes | no |
extern | 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
| no | no | yes | yes |
Semantic of auto | storage class | storage class | type | type |
Unicode support: literals u"x", U"x", u8"x", u'x', U'x', u8'x',
| no | no | yes | yes |
Computation at compile time
| no | no | yes | yes |
decltype | no | no | yes | yes |
| yes | yes | yes | yes |
noexcept 7)
| no | no | yes | yes |
nullptr | no | no | yes | yes |
register (was banned in C++17) | yes | yes | no | no |
static_assert | no | no | yes | yes |
thread_local | no | no | yes 8) | yes 8) |
Trigraph (i,e,. ??< ) | yes | yes | no | no |
Language features from C++ 2020 | ||||
| no | no | no | yes |
extended computation at compile time
| no | no | no | yes |
operator <=> | no | no | no | yes |
concept , requires | no | no | no | yes |
Co-routines | no | no | no | no 9) |
Modules | no | no | no | yes 10) |
predefined preprocessor names | ||||
| ==199409L | ==199409L | ==199409L | ==199409L |
| ==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 |
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 | ! |
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.