problem with short in va_arg list with 2.95.1 gcc

Franz Sirl Franz.Sirl-kernel at lauterbach.com
Sat Jan 8 13:27:25 EST 2000


Am Fre, 07 Jan 2000 schrieb Jim Terman:
>I am having a problem with code that looks for type short in a va_arg list
>when optimization is turned on.  There is no problem with no optimization.
>It compiles fine but produces an undefined reference to `__va_arg_type_violation'
>which I assume is delibrate to flag an error.  Is there a workaround besides
>turning off optimizations?
>
>If I compile the following file:
>test.c
>------
>#include <stdarg.h>
>#include <stdio.h>
>
>void printout(short d, ...)
>{
>  va_list arglist;
>
>  printf("%d ", d);
>  d = va_arg (arglist, short);
>  while (d)
>    {
>      printf("%s ", d);
>      d = va_arg (arglist, short);
>    }
>}
>
>int main()
>{
>  printout(1, 2, 0);
>  printout(2, 3,  4, 0);
>  return 0;
>}

There's no such thing like va_arg(arglist, short) in standard C, you can only
use default promotion types and typedef's thereof. So you have to use (short)
va_arg(arglist, int) here.

Franz.

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-dev mailing list