__VA_ARGS__ and __VA_OPT__Authors: Jay Ghiron
Date: 2026-06-11
Submitted against: C23
Status: Open
The identifiers
__VA_ARGS__and__VA_OPT__shall occur only in the replacement-list of a function-like macro that uses the ellipsis notation in the parameters.
(C23 6.10.5 "Macro replacement" paragraph 5.)
Consider the following program:
#if 1
#elif __VA_ARGS__
__VA_ARGS__
#define A __VA_ARGS__
#define B(...)__VA_ARGS__
#endif
Are any of these uses of __VA_ARGS__ valid? GCC, MSVC, and EDG
accept all of them. Clang rejects only the first use in the skipped
#elif directive, though it accepts the others. GCC will even accept
__VA_ARGS__ in #elif directives that are not skipped, see also
GCC issue
125655. The
wording appears to forbid all four uses of __VA_ARGS__, though I
doubt that it is intended for the last use to be invalid. Since the
directive syntax is relaxed for skipped directives, the fourth use of
__VA_ARGS__ does not appear to be in a replacement-list. Also, does
concatenation producing __VA_ARGS__ or __VA_OPT__ count as them
occurring?
#define X Y##__VA##_ARGS__
#define Y__VA_ARGS__
X
That is, is it unspecified whether or not this is valid?