Boost logo

Boost :

From: Edward Diener (eldiener_at_[hidden])
Date: 2020-09-18 02:57:39


On 9/17/2020 9:46 PM, Peter Dimov via Boost wrote:
> Edward Diener wrote:
>> I did discover that if gcc or clang is compiled at the C++03 level
>> with -pedantic there will be a ton of warnings, and if with
>> -pedantic-errros there will be a ton of errors for those warnings. The
>> main culprits, for C++03 at the pedantic level, are that variadic
>> macros are not supported and that empty macro arguments are undefined.
>
> Note that empty arguments for __VA_ARGS__ aren't allowed by C99, so
> clang -pedantic warns about them even in C++20 mode (even though C++20
> has __VA_OPT__.)
>
> <source>:3:4: warning: must specify at least one argument for '...'
> parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]
>
> clang -pedantic is way too pedantic, if you ask me.

The "empty macro arguments are undefined" in C++03 when -pedantic is
used refers to the fact that you can not pass nothing to an argument:

#define AMAC(x) x
AMAC()

which is totally legal in C++11 on up. I actually did not realize that
it was not legal in C++03, according to gcc/clang. Similarly:

#define AMACV(...) __VA_ARGS__
AMACV()

is also totally legal, except for C++03 evidently.

#define AMACV2(x,...) x __VA_ARGS__
AMACV2(arg,)

is fine, except for C++03 evidently but:

AMACV2(arg)

is fine only in C++20 on up.

I am still not sure why passing nothing is illegal in C++03, as opposed
to C++11 on up, but if both gcc and clang says it is not I guess they
are right.

I agree that -pedantic in clang and gcc is way too pedantic.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk