You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2008/06/23 22:10:28 UTC
Re: svn commit: r668225 - /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
elemings@apache.org wrote:
> Author: elemings
> Date: Mon Jun 16 09:31:03 2008
> New Revision: 668225
>
> URL: http://svn.apache.org/viewvc?rev=668225&view=rev
> Log:
> 2008-06-16 Eric Lemings <er...@roguewave.com>
>
> STDCXX-958
> * etc/config/src/VA_LIST_FUNC_MACRO.cpp: Initial version of
> configuration check for va-list function macros.
Out of curiosity, what do you expect to use this for? (FWIW,
I've often wished variadic macros were supported in C++
compilers but I could never come up with a workaround for
their absence, making them essentially unusable as a general
purpose feature.)
If we do come up with a use for the feature, I'd like to
suggest renaming the config test VARIADIC_MACRO.cpp.
Martin
Re: svn commit: r668225 - /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
Posted by Martin Sebor <se...@roguewave.com>.
Eric Lemings wrote:
>
>
>> -----Original Message-----
>> From: Travis Vitek [mailto:Travis.Vitek@roguewave.com]
>> Sent: Monday, June 23, 2008 4:59 PM
>> To: dev@stdcxx.apache.org
>> 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.
Which is why I don't think we'll be able to (or need to) use the
config macro in our code.
>>>
>> I think I've showed this trick before, but it won't work with template
>> parameters, only function parameters.
Right. This "trick" obviates the need for variadic macros in the
case of the rw_xxx() functions.
(Note that the trick isn't a general replacement for variadic macros
because it relies on a runtime mechanism while variadic macros are
a compile-time one.)
>>
>> 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:
There's no need for the additional complexity when we can just use
the #else case unconditionally. The !_RWSTD_NO_VARIADIC_MACROS case
provides no advantage over the workaround.
>
> #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.
RE: svn commit: r668225 - /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
Posted by Eric Lemings <Er...@roguewave.com>.
> -----Original Message-----
> From: Travis Vitek [mailto:Travis.Vitek@roguewave.com]
> Sent: Monday, June 23, 2008 4:59 PM
> To: dev@stdcxx.apache.org
> 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.
RE: svn commit: r668225 - /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
Posted by Travis Vitek <Tr...@roguewave.com>.
>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!");
Travis
>Brad.
>
RE: svn commit: r668225 - /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
Posted by Eric Lemings <Er...@roguewave.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com]
> Sent: Monday, June 23, 2008 3:50 PM
> To: dev@stdcxx.apache.org
> Subject: Re: svn commit: r668225 -
> /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
>
> Eric Lemings wrote:
> >
> >
> >> -----Original Message-----
> >> From: Martin Sebor [mailto:sebor@roguewave.com]
> >> Sent: Monday, June 23, 2008 2:10 PM
> >> To: dev@stdcxx.apache.org
> >> Subject: Re: svn commit: r668225 -
> >> /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
> >>
> >> elemings@apache.org wrote:
> >>> Author: elemings
> >>> Date: Mon Jun 16 09:31:03 2008
> >>> New Revision: 668225
> >>>
> >>> URL: http://svn.apache.org/viewvc?rev=668225&view=rev
> >>> Log:
> >>> 2008-06-16 Eric Lemings <er...@roguewave.com>
> >>>
> >>> STDCXX-958
> >>> * etc/config/src/VA_LIST_FUNC_MACRO.cpp: Initial version of
> >>> configuration check for va-list function macros.
> >> Out of curiosity, what do you expect to use this for? (FWIW,
> >> I've often wished variadic macros were supported in C++
> >> compilers but I could never come up with a workaround for
> >> their absence, making them essentially unusable as a general
> >> purpose feature.)
> >
> > The most obvious use would be in RWTest printf-like functions.
> >
> > I'm not sure how well variadic function macros mesh with variadic
> > templates but, if they do, I could take advantage of the feature
> > in tuples.
>
> 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.
Brad.
Re: svn commit: r668225 - /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
Posted by Martin Sebor <se...@roguewave.com>.
Eric Lemings wrote:
>
>
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com]
>> Sent: Monday, June 23, 2008 2:10 PM
>> To: dev@stdcxx.apache.org
>> Subject: Re: svn commit: r668225 -
>> /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
>>
>> elemings@apache.org wrote:
>>> Author: elemings
>>> Date: Mon Jun 16 09:31:03 2008
>>> New Revision: 668225
>>>
>>> URL: http://svn.apache.org/viewvc?rev=668225&view=rev
>>> Log:
>>> 2008-06-16 Eric Lemings <er...@roguewave.com>
>>>
>>> STDCXX-958
>>> * etc/config/src/VA_LIST_FUNC_MACRO.cpp: Initial version of
>>> configuration check for va-list function macros.
>> Out of curiosity, what do you expect to use this for? (FWIW,
>> I've often wished variadic macros were supported in C++
>> compilers but I could never come up with a workaround for
>> their absence, making them essentially unusable as a general
>> purpose feature.)
>
> The most obvious use would be in RWTest printf-like functions.
>
> I'm not sure how well variadic function macros mesh with variadic
> templates but, if they do, I could take advantage of the feature
> in tuples.
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
Martin
>
> In any case, I figured we'll need the config test sooner or later.
>
>> If we do come up with a use for the feature, I'd like to
>> suggest renaming the config test VARIADIC_MACRO.cpp.
>
> Fine by me. :)
>
> Brad.
RE: svn commit: r668225 - /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
Posted by Eric Lemings <Er...@roguewave.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com]
> Sent: Monday, June 23, 2008 2:10 PM
> To: dev@stdcxx.apache.org
> Subject: Re: svn commit: r668225 -
> /stdcxx/branches/4.3.x/etc/config/src/VA_LIST_FUNC_MACRO.cpp
>
> elemings@apache.org wrote:
> > Author: elemings
> > Date: Mon Jun 16 09:31:03 2008
> > New Revision: 668225
> >
> > URL: http://svn.apache.org/viewvc?rev=668225&view=rev
> > Log:
> > 2008-06-16 Eric Lemings <er...@roguewave.com>
> >
> > STDCXX-958
> > * etc/config/src/VA_LIST_FUNC_MACRO.cpp: Initial version of
> > configuration check for va-list function macros.
>
> Out of curiosity, what do you expect to use this for? (FWIW,
> I've often wished variadic macros were supported in C++
> compilers but I could never come up with a workaround for
> their absence, making them essentially unusable as a general
> purpose feature.)
The most obvious use would be in RWTest printf-like functions.
I'm not sure how well variadic function macros mesh with variadic
templates but, if they do, I could take advantage of the feature
in tuples.
In any case, I figured we'll need the config test sooner or later.
>
> If we do come up with a use for the feature, I'd like to
> suggest renaming the config test VARIADIC_MACRO.cpp.
Fine by me. :)
Brad.