Hi,
The sample code below will not compile due to an error with the va_list
code. When a type gets depromoted to another type with a smaller size,
the va_arg macro will use the va_arg_type_violation (a conveniently
undefined call in va-ppc.h in order to throw an error while compiling.),
this call being defined only for OPTIMIZED.
When compiling the valid code below with -O4, the lines getting the
va_arg with a float and char will generate this error. Why is this error
happening under GCC on PPC only? I've seen some posts about this problem
in the past, but the workaround people have found is to skip the
va_arg_type_violation (same as unoptimized.) This is not, IMHO, what
should happened. I could also invoke the va_arg call with a type that
doesn't generate an error, but that is also something not compatible
with other architectures.
Any other suggestions?
Thanks,
LdS
#include <stdio.h>
#include <stdarg.h>
enum {LONG, INT, CHAR, DOUBLE, FLOAT};
typedef long long Int64;
typedef int Int32;
typedef char Int8;
typedef double Float64;
typedef float Float32;
void foo_Int64(int id, Int64 value) {}
void foo_Int32(int id, Int32 value) {}
void foo_Int8(int id, Int8 value) {}
void foo_Float64(int id, Float64 value) {}
void foo_Float32(int id, Float32 value) {}
void bar(const int input, ...)
{
va_list args;
va_start(args, input);
switch(input) {
case LONG:
foo_Int64(input, va_arg(args, Int64));
break;
case DOUBLE:
foo_Float64(input, va_arg(args, Float64));
break;
case FLOAT:
/* compiler barfs here */
foo_Float32(input, va_arg(args, Float32));
break;
case INT:
foo_Int32(input, va_arg(args, Int32));
break;
case CHAR:
/* and here too. */
foo_Int8(input, va_arg(args, Int8));
break;
default:
}
va_end(args);
}
int main() { return 0; }
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]