This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Using C++20 __VA_OPT__ in a macro gives an error
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Edward Diener <eldlistmailingz at tropicsoft dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 30 Sep 2019 11:19:12 +0100
- Subject: Re: Using C++20 __VA_OPT__ in a macro gives an error
- References: <qmj3b0$3a85$1@blaine.gmane.org> <qmpanb$53g9$1@blaine.gmane.org>
On Sun, 29 Sep 2019 at 05:08, Edward Diener
<eldlistmailingz@tropicsoft.com> wrote:
>
> On 9/26/2019 3:25 PM, Edward Diener wrote:
> > I have a macro which uses the C++20 construct of __VA_OPT__. During a
> > compilation with og gcc-9.2 with the '-std=c++11' option the macro is
> > encountered in a header file, but it is never actually invoked in the
> > code. And yet gcc-9.2 gives an error of:
> >
> > error: __VA_OPT__ is not available until C++2a
> >
> > Why would this be happening ?
> >
> > I realize I can surround the macro with
> >
> > # if defined(__cplusplus) && __cplusplus > 201703L
> > #endif
> >
> > but my understanding is that macro code is not checked until it is
> > actually invoked during the preprocessing stage.
> >
> >
> >
>
> I know I saw this message but since I can not reproduce the occurrence
> in my code the OP should be ignored.
You were probably using an option like -pedantic-errors when you saw the error.
The token __VA_OPT__ is a reserved name, so in older standards that
don't define __VA_OPT__ the compiler is free to decide what it means.
If it wants to issue an error if that token is encountered, it can do
so. If you think there's a good reason to allow it and delay errors
until it is used please file it in bugzilla (although it might not be
feasible to change the preprocessor that way).