Keywords

Keywords are identifiers reserved by the language for special use. Although you can use them for preprocessor macro names, it is considered poor programming style. Only the exact spelling of keywords is reserved. For example, auto is reserved but AUTO is not.

Keywords for the C and C++ languages

Table 1. C and C++ keywords

auto1
break
case
char
const
continue
default
do

double
else
enum
extern2
float
for
goto
if

int
long
register
return
short
signed
sizeof
static

struct
switch
typedef
union
unsigned
void
volatile
while

Notes:
  1. C++11In C++11, the keyword auto is no longer used as a storage class specifier. Instead, it is used as a type specifier, which can deduce the type of an auto variable from the type of its initializer expression.C++11
  2. C++11The keyword extern was previously used as a storage specifier or as part of a linkage specification. The C++11 standard adds a third usage to use this keyword to specify explicit instantiation declarations.C++11
Begin C only

Keywords for the C language only

Standard C at the C99 and C11 levels also reserves the following keywords:
Table 2. C99 and C11 keywords


_Bool
_Complex
_Generic1
_Imaginary2
_Noreturn1

_Static_assert1
inline
restrict

Notes:
  1. C11This keyword is introduced due to the C11 language level.C11
  2. The keyword _Imaginary is reserved for possible future use. For complex number functionality, use _Complex; see Complex literals for details.
End C only
Begin C++ only

Keywords for the C++ language only

The C++ language also reserves the following keywords:
Table 3. C++ keywords

asm
bool
catch
class


const_cast
constexpr
delete

dynamic_cast
decltype
explicit
export
false
friend
inline
mutable
namespace

new
nullptr
operator
private
protected
public
reinterpret_cast
static_assert
static_cast
template

this
throw
true
try
typeid
typename
using
virtual
wchar_t

End C++ only

Keywords for language extensions (IBM extension)

In addition to standard language keywords, XL C/C++ reserves the following keywords for use in language extensions:
Table 4. Keywords for C and C++ language extensions

__alignof
__alignof__
__asm  (C only)
__asm__  (C only)
_attribute__
__attribute
bool (C only)8
__complex__

__const__
_Decimal323
_Decimal643
_Decimal1283

__decltype7

__extension__
__label__
__imag__
__inline__1
_Noreturn6
pixel8
__pixel8
__real__
__restrict
__restrict__
__signed__
__signed

__static_assert5
__volatile
__volatile__
__thread4
typeof2

__typeof__
vector8
__vector8

Notes:
  1. C onlyThe __inline__ keyword uses the GNU C semantics for inline functions. For details, see Linkage of inline functions.End C only
  2. C onlytypeof is recognized only when -qkeyword=typeof is in effect.End C only
  3. These keywords are recognized only when -qdfp is enabled.
  4. __thread is recognized only when -qtls is enabled.
  5. C only__static_assert is a keyword for C language extension for compatibility with the C++11 standard.End C only
  6. C++ only_Noreturn is a keyword for C++ language extension for compatibility with the C11 standard.C++ only
  7. C++ only__decltype is a keyword for C++ language extension. It enables you to use the C++11 decltype functionality in all language levels.C++ only
  8. These keywords are recognized only in a vector declaration context, when vector support is enabled.
Begin C++ only XL C++ reserves the following keywords as language extensions for compatibility with C99.
Table 5. Keywords for C++ language extensions related to C99

_Complex
_Imaginary1
_Pragma

restrict

Note:
  1. The keyword _Imaginary is reserved for possible future use. For complex number functionality, use _Complex; see Complex literals for details.
End C++ only

More detailed information regarding the compilation contexts in which extension keywords are valid is provided in the sections that describe each keyword.