NO

Author Topic: How do i fix 'warning #2030: '=' used in a conditional expression.'  (Read 3572 times)

Gary Willoughby

  • Guest
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?

Code: [Select]
#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;
}

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: How do i fix 'warning #2030: '=' used in a conditional expression.'
« Reply #1 on: January 02, 2010, 04:16:52 PM »
Code: [Select]
...
while((arg = va_arg(ap, int)) != 0)
...
May the source be with you

Gary Willoughby

  • Guest
Re: How do i fix 'warning #2030: '=' used in a conditional expression.'
« Reply #2 on: January 02, 2010, 04:47:01 PM »
Great thanks.