C++ Programming: Language Keywords

< C++ Programming < Programming Languages < C++ < Code

ISO C++ keywords

The C++98 standard recognized the following keywords:

  • and
  • and_eq
  • asm
  • auto
  • bitand
  • bitor
  • bool
  • break
  • case
  • catch
  • char
  • class
  • compl
  • const
  • const_cast
  • continue
  • default
  • delete
  • do

Specific compilers may (in a non-standard compliant mode) also treat some other words as keywords, including cdecl, far, fortran, huge, interrupt, near, pascal, typeof. Old compilers may recognize the overload keyword, an anachronism that has been removed from the language.

The current revision of C++, known as C++11, added some keywords:

  • alignas
  • alignof
  • char16_t
  • char32_t
  • constexpr
  • decltype
  • noexcept
  • nullptr
  • static_assert
  • thread_local

C++11 also added two special words which act like keywords in some contexts, but can be used as ordinary identifiers most of the time:

It would be bad practice to use these as identifiers when writing new code.

The C++98 keywords auto, default, delete and using have additional or changed uses in C++11.

Some old C++98 compilers may not recognize some or all of the following keywords:

  • and
  • and_eq
  • bitand
  • bitor
  • bool
  • catch
  • compl
  • const_cast
  • typeid
  • typename
  • using
  • wchar_t
  • xor
  • xor_eq

C++ reserved identifiers

Some "nonstandard" identifiers are reserved for distinct uses, to avoid conflicts on the naming of identifiers by vendors, library creators and users in general.

Reserved identifiers include keywords with two consecutive underscores (__), all that start with an underscore followed by an uppercase letter and some other categories of reserved identifiers carried over from the C library specification.

A list of C reserved identifiers can be found at the Internet Wayback Machine archived page: http://web.archive.org/web/20040209031039/http://oakroadsystems.com/tech/c-predef.htm#ReservedIdentifiers

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.