-qkeyword

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

  • C++ only__BOOL__ is defined to 1 by default; however, it is undefined when -qnokeyword=bool is in effect.
  • C only__C99_INLINE is defined to 1 when -qkeyword=inline is in effect.
  • __C99_RESTRICT is defined to 1 when -qkeyword=restrict is in effect.
  • C only__IBM_GCC_ASM is defined to 1 when -qkeyword=asm is in effect. (In C++ it is defined by default.)
  • __IBM__TYPEOF__ is defined to 1 when -qkeyword=typeof is in effect.

Examples

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

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us