Re: Support for __VA_OPT__ in gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 28 Sep 2019 at 04:29, Edward Diener wrote:
>
> 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.

You could also consult
https://gcc.gnu.org/projects/cxx-status.html#cxx2a which notes that
the support is incomplete.

> 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 ?

Yes, it's available as a GNU extension. You can get a diagnostic with
-std=c++14 -Wpedantic, but not with any -std=gnu++NN modes.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux