Title
Macro invocation in #include directive
Status
nad
Section
15.3 [cpp.include]
Submitter
David Krauss

Created on 2013-07-24.00:00:00 last changed 128 months ago

Messages

Date: 2013-09-15.00:00:00

Rationale (September, 2013):

The wording referring to preprocessing tokens “in the directive” is a clear enough indication that no tokens after the terminating newline are considered.

Date: 2022-11-20.07:54:16

According to 15.3 [cpp.include] paragraph 4,

A preprocessing directive of the form

    # include pp-tokens new-line

(that does not match one of the two previous forms) is permitted. The preprocessing tokens after include in the directive are processed just as in normal text (Each identifier currently defined as a macro name is replaced by its replacement list of preprocessing tokens.). If the directive resulting after all replacements does not match one of the two previous forms, the behavior is undefined.155 The method by which a sequence of preprocessing tokens between a < and a > preprocessing token pair or a pair of " characters is combined into a single header name preprocessing token is implementation-defined.

It might be inferred from the phrase “in the directive” that only tokens before the terminating newline would be available for macro expansion, and that consequently the closing right parenthesis of a function-style macro must appear on the same line. However, it would be clearer if it used language like that of 15.6.2 [cpp.subst] paragraph 1:

each argument's preprocessing tokens are completely macro replaced as if they formed the rest of the preprocessing file; no other preprocessing tokens are available.
History
Date User Action Args
2013-10-14 00:00:00adminsetmessages: + msg4716
2013-10-14 00:00:00adminsetstatus: open -> nad
2013-07-24 00:00:00admincreate