Boost logo

Boost Users :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-06-29 14:43:43


> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Dave Steffen

> Yes, I've seen this in the GCC documentation. Unfortunately, it
> doesn't help if you're doing the sort of preprocessor metaprogramming
> we're doing. In one case in particular, the end result of the macro
> really is supposed to be a _function declaration_, not a section of
> code.
>
> In another case, it shows up from the construct
>
>
> #define NUM_SIG_CONNECTION_FUNCTIONS_FOR_MEMBERS(first,last) \
> BOOST_PP_REPEAT_FROM_TO(BOOST_PP_ADD(first,1),BOOST_PP_ADD(last,2),\
> NUM_SIG_DECLARE_CONNECT,BOOST_PP_EMPTY)
>
>
> I don't claim to understand everything that's going on here (even
> remotely), but GCC 3.2 and 3.3 are very happy with the usage (in a
> header file)
>
>
> NUM_SIG_CONNECTION_FUNCTIONS_FOR_MEMBERS(0, MAX_SIGNAL_ARGS);
>
> while 3.4 complains about that semicolon. What I'm asking is A) does
> anyone know if 3.4 has a particular -Wno-extra-semicolon, or
> equivalent, to turn off that warning; or B) what is the proper
> preprocessor metaprogramming technique to silence the warning.

The proper technique is to get rid of the semicolon. A macro invocation is not
an expression, though it may expand to one, and it is not a function call.
Adding the semicolon and then trying to get around the warning (which should be
an error) only encourages the view that macros invocations and function calls
are equivalent. Nearly all macro-related problems (other than name collision)
are a result of this fundamentally flawed perspective. The use of all caps
should be make it obvious that a macro is involved. Making macro invocations
appear more like function calls is evil--don't do it.

Regards,
Paul Mensonides


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net