Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-03-04 17:58:05


Jonathan Turkanis wrote:
> When I compile the following simple program on VC6:
>
> #include <boost/preprocessor/facilities/empty.hpp>
> #include <boost/preprocessor/punctuation/comma_if.hpp>
>
> #define PARAM(has_param) BOOST_PP_IF(has_param, typename Param,
> BOOST_PP_EMPTY())
> #define MACRO(has_param)
> \
> template< PARAM(has_param) BOOST_PP_COMMA_IF(has_param)
> typename T> \
> struct name { };
> \
> /**/
>
> MACRO(0)
>
> int main() { return 0; }
>
> I get the following warnings:
>
> warning C4003: not enough actual parameters for macro
> 'BOOST_PP_IIF'
> warning C4003: not enough actual parameters for macro
> 'BOOST_PP_IIF_I'
> warning C4003: not enough actual parameters for macro
> 'BOOST_PP_IIF_0'
>
> It works fine on other compilers.
>
> Am I missusing the preprocessor library, or is this a problem with
> VC6? If the latter, is there a workaround, or should I just turn off
> warning 4003?

BOOST_PP_EMPTY() evaluates to nothing, so I would think that VC6 is
actually right. I'm probably wrong though, I'm no PP guru. ;) Anyway, I
think you should do:

   #define PARAM(has_param) BOOST_PP_IF( \
          has_param \
        , BOOST_PP_IDENTITY(typename Param) \
        , BOOST_PP_EMPTY)()

HTH,

-- 
Daniel Wallin

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