_argptr woes
Bill Baxter
dnewsgroup at billbaxter.com
Fri Mar 16 19:02:53 PDT 2007
Frits van Bommel wrote:
> kris wrote:
>> The D spec says:
>>
>> "The implementiations of these variadic functions have a special local
>> variable declared for them, _argptr, which is a void* pointer to the
>> first of the variadic arguments. To access the arguments, _argptr must
>> be cast to a pointer to the expected argument type"
>>
>>
>> To me, this means that a D compiler must implement _argptr in these
>> terms. Is that indeed the case, Walter? Or is my interpretation
>> incorrect?
>
> That would seem to be what it means.
> That would also seem to be a pretty big portability bug in the spec. On
> amd64 definitely !is(va_list == void*) :P. (at least for current GDC,
> GCC and any other compiler following
> http://www.x86-64.org/documentation/abi.pdf)
Sounds like a good opportunity to replace the whole _argptr/_arguments
hack with something more D-like. Something more like a TypeInfo. Say,
a VarArgInfo class which provides slightly higher level access to the
void*/TypeInfo[] pair. Then make it possible to use that as the last
argument to the vararg function:
int foo(char[] fmt, ... v) {
// v is a VarArgInfo here
}
Nice thing is this can coexist with _argptr/_arguments code. If you
don't specify a variable name for the vararg, you get _argptr/_arguments
behavior. If you do specify then you get a VarArgInfo with the
specified name.
--bb
More information about the Digitalmars-d
mailing list