> -----Original Message-----
> From: Travis Vitek [mailto:[EMAIL PROTECTED]
> Sent: Monday, June 23, 2008 4:59 PM
> To: [email protected]
> Subject: RE: svn commit: r668225 -
> /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
>
>
>
> >Eric Lemings wrote:
> >
> >> Martin Sebor wrote:
> >>
> >>
> >> My point was that I couldn't find a way to use a feature
> >> that depends on variadic macros on platforms where they
> >> are not supported. In other words, I can't picture what
> >> the #else branch below would look like:
> >>
> >> #ifndef _RWSTD_NO_VARIADIC_MACROS
> >> # define RW_ASSERT(expr, ...) \
> >> rw_assert (expr, 0, __LINE__, __VA_LIST__)
> >> #else
> >> # define RW_ASSERT(expr, ???) ...
> >> #endif
> >
> >You're right. There is no backward-compatible workaround which
> >essentially rules out using variadic macros in these cases.
> >
>
> I think I've showed this trick before, but it won't work with template
> parameters, only function parameters.
>
> struct Variadic
> {
> void operator()(const char* fmt, ...);
> };
>
> #define VARIADIC Variadic().operator()
>
> Of course you would use it like this...
>
> VARIADIC("hello %s", "world!");
Had forgotten about that. :)
So, we have something like this:
#ifndef _RWSTD_NO_VARIADIC_MACROS
# define RW_ASSERT(expr, ...) \
rw_assert (expr, 0, __LINE__, __VA_LIST__)
#else
struct __rw_assert {
int operator()(int expr, const char* file, int line,
const char* fmt, ...) {
va_list va;
va_start (va, fmt);
_rw_vdiag (diag_assert, 0 == expr, file, line, fmt, va);
va_end (va);
return success;
}
};
# define RW_ASSERT __rw_assert().operator()
#endif
That pretty close?
And why is there a 2nd parameter in rw_assert() if its never used? :P
Brad.