2009/11/16 Surya Kiran Gullapalli <suryakiran.gullapalli@gmail.com>
This does not seems to be working, I keep getting the error C4003, not enough actual parameters for macro 'PP_ARG_N'

GCC says, PP_ARG_N expects 65 args, where as it is getting only 3. I'm kinda lost here .

Hm... that's because both branches of BOOST_PP_IF always get evaluated. We need to evaluate only one of them.

 #define FOO_ARGS(...) \
    BOOST_PP_IF( \
        BOOST_PP_EQUAL(PP_NARG(__VA_ARGS__), 2), \
        (__VA_ARGS__, 0), \
        (__VA_ARGS__))

#define FOO(...) BOOST_PP_EXPAND(FOO_IMPL FOO_ARGS(__VA_ARGS__))

I'm attaching a complete solution.

Roman Perepelitsa.