Example program:
#include <stdarg.h>
void test(int x, ...)
{
va_list ap;
va_start(ap, x);
printf("%d %f\n", x, va_arg(ap, float));
va_end(ap);
}
void main()
{
float f;
f = 1.4;
test(1, f);
}
Output:
1 36893488147419103232.000000
Not a bug in DJGPP. A lack of understanding of the C language, mainly.
Floats can never be passed to any variable-arguments function.
They will get promoted to double, automatically. So you cannot
expect vararg(,) to give you back a float, either.
In the words of the ANSI/ISO C Standard:
If there is no actual next argument, or if `type` is not
compatible with the type of the actual argumet (as promoted
according to the default argument promotion rules), the
behaviour is undefined.
This also is the reason that printf(), unlike scanf() has no
separte formats at all for printing floats, or short ints, or
anything like that: they end up as doubles or normal ints
inside printf(), anyway, so there's no point to treat them
specially.