Title
Directives in multi-line macro arguments
Status
tentatively ready
Section
15.7.1 [cpp.replace.general]
Submitter
Yin Xinyu

Created on 2026-08-14.00:00:00 last changed yesterday

Messages

Date: 2026-09-03.23:06:47

Proposed resolution (approved by CWG 2026-09-01):

Change in 15.7.1 [cpp.replace.general] paragraph 14 as follows:

... If there are sequences of preprocessing tokens is whitespace containing at least one new-line character immediately followed by a directive-introducing token (15.1 [cpp.pre]) within the list of arguments that would otherwise act as preprocessing directives, [Footnote: A conditionally-supported-directive is a preprocessing directive regardless of whether the implementation supports it.] the program is ill-formed.
Date: 2026-08-14.00:00:00

(From submission #975.)

Consider:

  #define FOO(...)
  FOO(
  #include <iostream>
  )

This is ill-formed per 15.7.1 [cpp.replace.general] paragraph 14.

... If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, [Footnote: ...] the program is ill-formed.

However, what about this:

  #define FOO(...)
  FOO(
  #if )

According to 15.7.1 [cpp.replace.general] paragraph 14, the closing parenthesis is not part of the analysis for a "preprocessing directive" (note "within"), but 15.1 [cpp.pre] paragraph 2 requires a trailing new-line for some text to be recognized as a preprocessing directive (which is not "within" the arguments here).

History
Date User Action Args
2026-09-03 23:06:47adminsetstatus: open -> tentatively ready
2026-08-23 09:05:11adminsetmessages: + msg8664
2026-08-14 00:00:00admincreate