Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Jun 1997 15:56:55 +0300
From:      Anatoly Vorobey <mellon@pobox.com>
To:        Steve Howe <un_x@anchorage.net>
Cc:        hackers@freebsd.org
Subject:   Re: signed/unsigned cpp
Message-ID:  <19970602155655.20481@techunix.technion.ac.il>
References:  <19970601100320.37936@techunix.technion.ac.il> <Pine.BSF.3.95q.970601234922.1753E-100000@aak.anchorage.net>

next in thread | previous in thread | raw e-mail | index | archive | help
You, Steve Howe, wrote on Sun, Jun 01, 1997 at 11:55:29PM -0800:
> 
> >      The type `char' is always a distinct type from each of `signed
> >      char' or `unsigned char', even though its behavior is always just
> >      like one of those two.
> 
> ok, but why?  i'm trying to understand any possible reason for this,
> and can't think of any ...  (my teachers used to hate me :)
> i've written assemblers and mini-compilers and have some
> understanding of what's necessary, but i don't get this!
> what's is the point of this rule?  as it says,
> "its behaviour is always just like on of those two" ...

Because if you assign char value to signed char var, the
program isn't portable and isn't ANSI C, even if char
*is* signed char on the intended architecture - it can
be unsigned on others. The compiler should have some means
to recognize this potential unportability. If char was
treated as signed char internally, it wouldn't be possible.

For another reason, consider cross-compiling.

-- 
Anatoly Vorobey,
mellon@pobox.com http://pobox.com/~mellon/
"Angels can fly because they take themselves lightly" - G.K.Chesterton



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970602155655.20481>