how gcc thinks `char' as signed char or unsigned char ?

Andrew Haley aph@redhat.com
Wed Mar 5 09:58:00 GMT 2008


PRC wrote:
> ---------------------------------
> int main()
> {
> 	char a = -7;
> 	
> 	if( a < -9 )
> 		printf("a");
> 	else
> 		printf("b");
> }
> ---------------------------------
> sde-gcc -c a2.c
> c:/a2.c: In function `main':
> c:/a2.c:6: warning: comparison is always false due to limited range of data type
> 
> It may be the reason for this warning that gcc thinks `char' as 'unsigned char' by default.
> Can I change the default configuration by modifying some configuration file?
> Or this feature can't be changed after gcc has been built?

-fsigned-char

The signedness of characters is part of a machine's ABI.  If you
really need to have unsigned chars, declare them as such.

Andrew.



More information about the Gcc-help mailing list