This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: how gcc thinks `char' as signed char or unsigned char ?
- From: Andrew Haley <aph at redhat dot com>
- To: PRC <panruochen at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 05 Mar 2008 09:57:12 +0000
- Subject: Re: how gcc thinks `char' as signed char or unsigned char ?
- References: <200803051719569448630@gmail.com>
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.