ppc_8xx-gcc from eldk strange behaviour

DI BACCO ANTONIO - technolabs Antonio.DiBacco at technolabs.it
Wed Aug 29 04:56:10 EST 2007

Consider the following C code snippet:

#include <stdio.h>

int main()
  char x = -4;
  if (x < 0)
    printf("x is negative\n");
    printf("x is positive\n");  

If I compile it with host gcc, there is no warning and the message "x is negative" is printed.
If I compile it with ppc_8xx-gcc there is a warning "main.c:11: warning: comparison is always false due to limited range of data type" and the program prints message "x is positive". 
To correct the problem I have to put signed before char.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ozlabs.org/pipermail/linuxppc-embedded/attachments/20070828/cb745279/attachment.htm 

More information about the Linuxppc-embedded mailing list