How do i fix 'warning #2030: '=' used in a conditional expression.'

Started by Gary Willoughby, January 02, 2010, 03:58:56 PM

Previous topic - Next topic

Gary Willoughby

Why do i still get a:

warning #2030: '=' used in a conditional expression.

even when i'm surrounding the assignment in the while test with parenthesis?


#include <stdio.h>
#include <stdarg.h>

int Sum(int a, int b, ...)
{
   int arg;
   int Sum = a + b;

   va_list ap;
   va_start(ap, b);

   while((arg = va_arg(ap, int)))
   {
       Sum += arg;
   }
   va_end(ap);

   return Sum;
}

int main(int argc, char *argv[])
{
   printf("%d\n", Sum(1, 2, 4, 8));

   return 0;
}

TimoVJL

May the source be with you