public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Support for __VA_OPT__ in gcc
@ 2019-09-28  3:28 Edward Diener
  2019-09-30 10:08 ` Jonathan Wakely
  0 siblings, 1 reply; 12+ messages in thread
From: Edward Diener @ 2019-09-28  3:28 UTC (permalink / raw)
  To: gcc-help

Given this program:

#define PP_THIRD_ARG(a,b,c,...) c
#define VA_OPT_SUPPORTED_I(...) PP_THIRD_ARG(__VA_OPT__(,),1,0,)
#define VA_OPT_SUPPORTED() VA_OPT_SUPPORTED_I(?)

#include <iostream>

int main()
      {
      int result = VA_OPT_SUPPORTED();
      std::cout << result;
      return 0;
      }

as a test for __VA_OPT__ support in a C++ compiler ( taken from
https://stackoverflow.com/questions/48045470/portably-detect-va-opt-support 
)
I have discovered that __VA_OPT__ support started with gcc-8.1. However 
I have also discovered that the support occurs no matter what the C++ 
standard level is used for the compilation and not just when the option 
is 'std=c++2a'. In other words I can compile the program with 
'std=c++03', link and run the program and the program will output 1, 
showing __VA_OPT__ support, rather than 0, which shows that __VA_OPT__ 
is not supported.

If I compile the above with any version of gcc lower than gcc-8.1 the 
program will outpyt 0 no matter what -std mode I use.

Is this intended, that the C++20 __VA_OPT__ support works in all modes 
for gcc-8.1 and higher ?

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-10-01 15:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-28  3:28 Support for __VA_OPT__ in gcc Edward Diener
2019-09-30 10:08 ` Jonathan Wakely
2019-09-30 13:20   ` Edward Diener
2019-09-30 13:34     ` Jonathan Wakely
2019-09-30 13:35       ` Jonathan Wakely
2019-09-30 14:53       ` Edward Diener
2019-09-30 15:22         ` Jonathan Wakely
2019-10-01  0:25           ` Edward Diener
2019-10-01 11:13             ` Jonathan Wakely
2019-10-01 14:59               ` Edward Diener
2019-10-01 15:36                 ` Jonathan Wakely
2019-10-01 15:39                   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).