va_list ARM changes
Johannes Pfau
nospam at example.com
Fri Aug 31 05:05:47 PDT 2012
Am Fri, 31 Aug 2012 12:49:37 +0100
schrieb Iain Buclaw <ibuclaw at ubuntu.com>:
> Part of where you are going wrong is that 'va_arg (va_list, TypeInfo,
> void*)' should only be used when the static type is indeterminable.
> This is typically only for structs and classes. All basic types
> should go through the normal va_arg template functions - these
> actually get expanded intrinsically by the gcc backend and *do* the
> right thing, even for your float example.
OK, then everything is working as expected.
>
> Now that is not to say that you can't use 'va_arg (va_list, TypeInfo,
> void*)' for basic types, but you do need to be aware of type
> promotions when it comes to va_args. :-)
>
> Eg:
>
> void main()
> {
> test2("", cast(float)3.45f, "TestTest"); // float is promoted to
> double when passed as a vararg.
> }
>
> void test2(string input, ...)
> {
> double f;
> string s;
> va_list list;
> va_start(list, input);
> va_arg(list, typeid(typeof(f)), &f);
> va_arg(list, typeid(typeof(s)), &s);
> va_end(list);
> writefln("%s %s", f, s);
> }
>
>
> And you'll see that test2() in your paste works.
>
Still doesn't work for me, but if basic types should not be used with
that va_arg overload and as the templated version works fine anyway it
doesn't matter.
More information about the D.gnu
mailing list