This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]