-qkeyword

Category

Language element control

Pragma equivalent

None

Purpose

Controls whether the specified name is treated as a keyword or as an identifier whenever it appears in your program source.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-keyword---.                    
>>- -q--+-nokeyword-+--=--keyword_name-------------------------><

Defaults

By default, all the built-in keywords defined in the C and C++ language standards are reserved as keywords.

Usage

You cannot add keywords to the language with this option. However, you can use -qnokeyword=keyword_name to disable built-in keywords, and use -qkeyword=keyword_name to reinstate those keywords.

C++ onlyThis option can be used with all C++ built-in keywords.C++ only

C++11This option can be used with the following keywords introduced by the C++11 standard:

These keywords are reserved at all C++ language levels by default. The -qlanglvl suboption of each feature or the -qlanglvl=[no]extended0x group option can only enable or disable the feature, but cannot enable or disable the associated keyword. If you specify the -qkeyword=keyword_name option, the compiler reserves the keyword_name (constexpr, decltype, nullptr or static_assert) as a keyword, but the associated feature is not enabled automatically.

The following table demonstrates how the compiler behaves when different option settings are in effect.
Table 2. Compiler behaviour under different option settings
  -qkeyword=keyword_name enabled -qnokeyword=keyword_name enabled
The -qlanglvl suboption or group option is enabled The feature is enabled. keyword_name is reserved as a keyword. The feature is enabled. keyword_name is reserved as a keyword.

A warning message is issued to indicate that the -qnokeyword=keyword_name option is ignored.
Neither the -qlanglvl suboption nor group option is enabled The feature is disabled. keyword_name is reserved as a keyword.

An error message is issued in contexts where keyword_name should not be used while the keyword is reserved but the feature is disabled. You can either enable the feature by using the -qlanglvl suboption or group option or disable the keyword by using the -qnokeyword=keyword_name option.
The feature is disabled. keyword_name is treated as an identifier token.

When the -qwarn0x option is enabled, a warning message is issued when it is expected that turning on the feature will modify the validity or semantics of the program.
C++11
C only This option can also be used with the following C keywords:
  • asm
  • inline
  • restrict
  • typeof
Note: asm is not reserved as a keyword at the stdc89 or stdc99 language level.
C only

Predefined macros

Examples

C++ only You can reinstate bool with the following invocation:
xlc++ -qkeyword=bool
C++ only
C only You can reinstate typeof with the following invocation:
xlc -qkeyword=typeof
C only

Related information