Using C++20 __VA_OPT__ in a macro gives an error

Edward Diener eldlistmailingz@tropicsoft.com
Thu Sep 26 19:25:00 GMT 2019


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.




More information about the Gcc-help mailing list