View previous topic :: View next topic |
Author |
Message |
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Tue Dec 13, 2005 4:24 am Post subject: std.stdarg not available? |
|
|
I am attempting to compile the recent Mango tree with -version=Ares on win32. The process interrupted because Mango keeps trying to import "std.stdarg" into a few files.
I had a look in Ares. Obviously, std.stdarg is not there, although std.c.stdarg exists. Phobos has both, one for argument lists with extern(D) linkage (std.stdarg) and the other one for variable argument lists with extern(C) linkage.
Does Ares not include std.stdarg for a reason? For now, I can workaround the problem easily enough by manually adding std.stdarg.
Thanks.
-JJR |
|
Back to top |
|
|
sean
Joined: 24 Jun 2004 Posts: 609 Location: Bay Area, CA
|
Posted: Tue Dec 13, 2005 11:31 am Post subject: |
|
|
Hrm, I suppose I should add std.stdarg. I'd overlooked it. |
|
Back to top |
|
|
sean
Joined: 24 Jun 2004 Posts: 609 Location: Bay Area, CA
|
Posted: Tue Dec 13, 2005 11:41 am Post subject: |
|
|
Odd. Here is the code in std.stdarg:
Code: | template va_arg(T)
{
T va_arg(inout va_list _argptr)
{
T arg = *cast(T*)_argptr;
_argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1));
return arg;
}
} |
and here is the same function in std.c.stdarg:
Code: | template va_arg(T)
{
T va_arg(inout va_list ap)
{
T arg = *cast(T*)ap;
ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)));
return arg;
}
} |
Perhaps it's because I haven't had my coffee yet, but I can't see any difference. What am I missing? Note that the type of va_list is void* in both cases. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Tue Dec 13, 2005 2:46 pm Post subject: |
|
|
I really don't know. I guess _argptr and ap are pretty much the same? I don't get why va_list is cast to (void*) and then back to (va_list) again in std.c.stdarg.
You're right it does look pretty much the same.
Nonetheless, Walter calls one for extern(C) and the other for extern(D).
-JJR |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Tue Dec 13, 2005 3:48 pm Post subject: |
|
|
Drat ~ forgot to mention this to you, Sean.
Is argptr a void* on all platforms? Is GDC like this for the C version? |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Tue Dec 13, 2005 7:04 pm Post subject: |
|
|
So what is going to be done?
Since std.stdarg and std.c.stdarg are pretty much the same, I guess we only need one of these then? std.c.stdarg has a little extra, so will that one stay?
Kris, are you going to change Mango for the Ares compile then?
Thanks,
John |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Tue Dec 13, 2005 7:31 pm Post subject: |
|
|
Let's wait to see what Sean wants to do?
My preference would be to keep the std.stdarg and drop the std.c version, assuming they perform the same function. The rationale is that there needs to be at least a D version. |
|
Back to top |
|
|
sean
Joined: 24 Jun 2004 Posts: 609 Location: Bay Area, CA
|
Posted: Wed Dec 14, 2005 2:07 am Post subject: |
|
|
I haven't decided what to do about this yet. std.c.stdarg is required by the C99 spec, so I'd like to keep it, but it does seem appropriate that there be a D version as well. I may add a std.stdarg file that just publicly imports std.c.stdarg for now. |
|
Back to top |
|
|
|