From owner-freebsd-hackers Mon Jun 2 05:57:45 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA17813 for hackers-outgoing; Mon, 2 Jun 1997 05:57:45 -0700 (PDT) Received: from techunix.technion.ac.il (mellon@techunix.technion.ac.il [132.68.1.28]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id FAA17808 for ; Mon, 2 Jun 1997 05:57:38 -0700 (PDT) Received: (from mellon@localhost) by techunix.technion.ac.il (8.8.5/8.8.5) id PAA17304; Mon, 2 Jun 1997 15:56:55 +0300 (IDT) Message-ID: <19970602155655.20481@techunix.technion.ac.il> Date: Mon, 2 Jun 1997 15:56:55 +0300 From: Anatoly Vorobey To: Steve Howe Cc: hackers@freebsd.org Subject: Re: signed/unsigned cpp References: <19970601100320.37936@techunix.technion.ac.il> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.64 X-Disclaimer: I was young, I needed the money! Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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