Boost logo

Boost-Build :

Subject: Re: [Boost-build] [requires] cxx11_variadic_macros
From: Edward Diener (eldiener_at_[hidden])
Date: 2015-10-15 20:09:02

On 10/15/2015 5:35 PM, Raffi Enficiaud wrote:
> Le 15/10/15 04:19, Edward Diener a écrit :
>> On 10/14/2015 2:53 PM, Raffi Enficiaud wrote:
>>> So you're saying that for clang, we should have BOOST_PP_VARIADICS=1.
>>> Why isn't it the case then? Explicitly setting toolset=clang does not
>>> help.
>> This is my error. Originally clang by default did not have variadic
>> macro support in Boost PP. Then because of programmer feedback I turned
>> on variadic macro support by default for clang in Boost PP
>> unconditionally. This however lead to a slew of clang warnings when
>> clang was compiled in C/C++ mode less than C99 or C++11. So then I
>> changed Boost PP so that clang, like gcc, only has variadic macro
>> support by default when compiling in C99 or C++11 mode. I had forgot
>> about that final change I made for clang when I responded to this
>> message.
>> You can force variadic macro support for a compiler in Boost PP by
>> defining BOOST_PP_VARIADICS=1 before Boost PP headers are included, or
>> you can make sure of variadic macro support by default for clang and gcc
>> by compiling in C99 ( for C ) or C++11 ( for C++ ) mode.
> Right now what I am doing is that I activate the variadic macro support
> for clang and disable this specific warning.
> However, I wanted to do the same for GCC, but somehow I am unable to
> deactivate this specific warning:
> This very simple test case:
> #pragma GCC diagnostic ignored "-Wvariadic-macros"
> #include <stdio.h>
> #define BLABLA(...) printf(__VA_ARGS__)
> int main()
> {
> BLABLA("%d%d%d",1,2,3);
> }
> shows a bunch of warnings with "-pedantic" (expected) but it looks to me
> impossible to deactivate with the #pragma (while if I have this on the
> command line: "-pedantic -Wno-variadic-macros", it just works).
> This is a annoying indeed for the user to have so many warnings... but
> this is with "-pedantic" so its up to the users (and also boost.test
> code is not really targeted to be used in another library: the warnings
> ends at the compilation of a test module and are not propagated to other
> libraries).
> Also, without "-pedantic" and without the #pragma, I get not warning at
> all on this simple case: the default for GCC is to accept that code
> without complain.
> I was not able to silence the warning on our unit tests, but it turned
> out that the "-pedantic" is activated automatically by
> <warnings>all
> To summarize:
> - boost.test unittests are compiling with "-pedantic" which generates a
> lot of warnings when BOOST_PP_VARIADICS=1 is enforced
> - it looks impossible to remove the variadic macro warnings with
> #pragmas for GCC, at least when using -pedantic.
> - when I remove the -pedantic, I still have the warnings, I guess
> because of "<warnings>all"
> - when I add -Wno-variadic-macro to the configuration, the warnings are
> gone.
> So it looks more or less safe to enforce BOOST_PP_VARIADICS=1 in
> boost.test.

I don't know what you are using Boost PP and BOOST_PP_VARIADICS=1 for in
Boost test. But if any of it propagates to the user of Boost test do
realize that if BOOST_PP_VARIADICS=1 and you are using Boost PP and the
compiler the user is using does not support variadic macros, the user
will see preprocessor errors. With that said there are realistically
very few compiler the user may be using that does not support variadic
macros, but they do exist, especially for older versions of compilers
that are not gcc or clang or VC++8 or above.

As far as gcc is concerned I have always used -Wno-variadic-macro to
silence any warnings.

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at