Quasar
Moderator

Posts: 4484
Registered: 08-00 |
Thanks, that is in fact what I decided to do last night while working on this though ;)
The problem came in with the pvsnfmt_int function, however, which used different va_arg() calls depending on the formatting character in use. To replace that business I have had to introduce a union type that is used to pass in the parameter. It's pretty hackish if you ask me.
I found that the problem, which you were right about, stems all the way back to the C89 standard. Since it declines to define va_list even to the extent that you know you can pass it to more than one function reliably, compiler writers are free to do it in whatever way they see fit. C99 didn't fix this, but in fact made it worse by introducing a ridiculous va_copy mechanism which only works if you want to pass the list to each function from the beginning.
Because of this standards loophole, and what must be some really icky internal design, GCC 64-bit has va_list implemented as an array type, which is what was causing the type matching error. Evidently, instead of using a different, sane calling convention for varargs functions like Microsoft does, GCC uses the normal AMD64 calling convention for them, and copies the first 6 arguments passed in registers into this array. That really sounds like the paragon of efficiency...
Varargs functions ought to be implemented with a stdc calling convention on any machine that supports a stack, if you ask me.
|