Name
n3908, alx-0092r1 - Define macro-parameter-list (editorial)
Principles
- Avoid ambiguities
Category
Preprocessor
Authors
Alejandro Colomar <alx@kernel.org>
Reported-by: Joseph Myers <josmyers@redhat.com>
History
<https://www.alejandro-colomar.es/src/alx/alx/std/wg14/alx-0092.git/>
r0 (2026-05-21):
- Initial draft.
r1 (2026-06-03; n3908):
- tfix
- Clarify when two macro parameter lists are identical.
- Adopt wording from Issue 1066. [Joseph]
Description
On 2026-05-20T21:01:15+0000, Joseph Myers wrote:
> It's questionable whether the existing wording about duplicate
> function-like macro definitions, "that has the same number and
> spelling of parameters", is really sufficient to require the
> two definitions agree on the presence or absence of "..." as
> well as the number and spellings of names of named parameters
Let's add a syntactic element 'macro-parameter-list' that will
allow us improve the wording.
As a side effect, this will simplify future changes I'm working
on that affect the preprocessor, by having a specific term to
refer to the macro parameter list.
See also
Issue 1066
<https://www.open-std.org/jtc1/sc22/wg14/issues/c23/log.html#issue1066>
Proposed wording
Based on N3886.
6.10.5.1 Macro replacement :: General
@@ Syntax, p1
define-directive:
<b># define</b> identifier replacement-list new-line
- <b># define</b> identifier lparen identifier-list(opt) <b>)</b> replacement-list new-line
- <b># define</b> identifier lparen <b>... )</b> replacement-list new-line
- <b># define</b> identifier lparen identifier-list <b>, ... )</b> replacement-list new-line
+ <b># define</b> identifier lparen macro-parameter-list <b>)</b> replacement-list new-line
...
replacement-list:
...
+macro-parameter-list:
+ identifier-list(opt)
+ <b>...</b>
+ identifier-list <b>, ...</b>
identifier-list:
...
@@ Constraints, p2-1
+Two macro parameter lists are identical
+if and only if
+they have the same number and spelling of parameters
+and they agree in use of the final ellipsis.
@@ Constraints, p3
An identifier currently defined as an object-like macro
shall not be redefined
by another #define preprocessing directive
unless
the second definition is an object-like macro definition
and the two replacement lists are identical.
Likewise,
an identifier currently defined as a function-like macro
shall not be redefined
by another #define preprocessing directive
unless
the second definition is a function-like macro definition
+,
-that has the same number and spelling of parameters,
+the two macro parameter lists are identical,
and the two replacement lists are identical.
@@ Semantics, p11
A preprocessing directive of the form
- <b># define</b> identifier lparen identifier-list(opt) <b>)</b> replacement-list new-line
- <b># define</b> identifier lparen <b>... )</b> replacement-list new-line
- <b># define</b> identifier lparen identifier-list <b>, ... )</b> replacement-list new-line
+ <b># define</b> identifier lparen macro-parameter-list <b>)</b> replacement-list new-line
defines a function-like macro with parameters,
whose use is similar syntactically to a function call.
The parameters are specified by
-the optional list of identifiers,
+the macro parameter list,
-whose scope
+and their scope
extends from their declaration
-in the identifier list
+in the macro parameter list
until the new-line character
that terminates the #define preprocessing directive.