Re: [RFC PATCH] pre-process: add __VA_OPT__ support

Al Viro <[email protected]> Wed, 25 Feb 2026 06:40:03 +0000
Newsgroups org.kernel.vger.linux-sparse
Message-ID <20260225064003.GD1762976@ZenIV>
On Tue, Feb 24, 2026 at 09:29:50PM -0800, Eric Zhang wrote:
> Add __VA_OPT__ support (C23 6.10.5) including some tests.
> 
> At expansion time, substitute() checks whether the variadic
> argument is empty: if so, skip the region between the markers;
> otherwise, process the enclosed tokens normally.
> 
> Signed-off-by: Eric Zhang <[email protected]>
> ---
> Discussed this with Chris during lunch yesterday and got curious
> about the problem, so made a few attempts.  Introducing
> TOKEN_VA_OPT_START/END feels a bit like an anti-pattern, but I
> couldn't find a cleaner way to handle it without new token types.
> Happy to hear suggestions.

Your variant will break with __VA_OPT__ following #.  It won't do the
right thing with ## either, AFAICS, in case when __VA_OPT__ token list
is empty.