Fix bug caused by use of va_arg in argument list.

Evaluation order of arguments is not specified in C++.
The va_arg() macro has order-dependent side effects.
Therefore the use of va_arg in an argument list has unpredictable
effects. This commit changes the code to call va_arg in a well-defined
order.
Merge pull request #37 from dimatura/va_arg_bugfix

Fix bug caused by use of va_arg in argument list.