On 31 August 2012 13:05, Johannes Pfau <nos...@example.com> wrote: > Am Fri, 31 Aug 2012 12:49:37 +0100 > schrieb Iain Buclaw <ibuc...@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. >
Boo! I should have really brought my ARM device with me so I could test this... unfortunately I left it at home 300 miles away. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';