Feature-testing preprocessor predicates for C++17 (original) (raw)

defined-macro-expression:

defined identifier

defined ( identifier )

h-preprocessing-token:

any preprocessing-token other than >

h-pp-tokens:

h-preprocessing-token

h-pp-tokens h-preprocessing-token

has-include-expression:

__has_include ( <h-char-sequence> )

__has_include ( "q-char-sequence" )

__has_include ( string-literal )

__has_include ( < h-pp-tokens > )

The expression that controls conditional inclusion shall be an integral constant expression except that identifiers (including those lexically identical to keywords) are interpreted as described below146 and it may contain zero or more defined-macro-expressions and/or has-include-expressions as unary operator expressions. of the form

defined identifier

or

defined ( identifier )

which evaluate A defined-macro-expression evaluates to 1 if the identifier is currently defined as a macro name (that is, if it is predefined or if it has been the subject of a #define preprocessing directive without an intervening #undef directive with the same subject identifier),0 if it is not.

The third and fourth forms of has-include-expression are considered only if neither of the first or second forms matches, in which case the preprocessing tokens are processed just as in normal text.

The header or source file identified by the parenthesized preprocessing token sequence in each contained has-include-expression is searched for as if that preprocessing token sequence were the pp-tokens in a #include directive, except that no further macro expansion is performed. If such a directive would not satisfy the syntactic requirements of a#include directive, the program is ill-formed. The has-include-expression evaluates to 1 if the search for the source file succeeds, and to 0 if the search fails.

The #ifdef and #ifndef directives, and the defined conditional inclusion operator, shall treat __has_include as if it were the name of a defined macro. The identifier __has_include shall not appear in any context not mentioned in this section.