From owner-freebsd-hackers Wed Jun 4 07:00:49 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id HAA29268 for hackers-outgoing; Wed, 4 Jun 1997 07:00:49 -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 HAA29250 for ; Wed, 4 Jun 1997 07:00:37 -0700 (PDT) Received: (from mellon@localhost) by techunix.technion.ac.il (8.8.5/8.8.5) id QAA13705; Wed, 4 Jun 1997 16:56:32 +0300 (IDT) Message-ID: <19970604165631.47148@techunix.technion.ac.il> Date: Wed, 4 Jun 1997 16:56:31 +0300 From: Anatoly Vorobey To: mark thompson Cc: hackers@freebsd.org Subject: Re: signed/unsigned cpp References: <19970604124524.945.qmail@squirrel.tgsoft.com> 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, mark thompson, wrote on Wed, Jun 04, 1997 at 12:45:24PM -0000: > if i am using an "unsigned char *", i expect my code to use an > "unsigned char *". it does not benefit any cross-compiler > or any other architecture to say "no - i will use it as > a signed char *". > > Actually, 'char' is a fine, useful and portable type, if you use it for > 7-bit characters, or integers 0..127. Not at all portable. Char, either signed or unsigned, is _not_ guaranteed to occupy 8 bits, and you're _not_ guaranteed by the standard that there's enough room in char for 7-bit numbers. There have been machines in use with 6-bit chars, as well as 12-bit chars and 16-bit chars. In C, "byte" does _not_ mean 8 bits; it means whatever number of bits char takes up on this architecture. Therefore, it's true (trivially) that "char takes up 1 byte", but it doesn't mean you can _portably_ store 127 in it ;) Of course, it's true that on just about any modern platform, char is 8, 16 or 32 bits, and int is 32 or 64; the machines with 33, 17 and 24-bitted ints are practically gone. But for me, personally, it's a pity; life's more interesting when there's greater variety of designs. And I wish there were useful machines built on three-stated design (instead of bits) around ;) -- Anatoly Vorobey, mellon@pobox.com http://pobox.com/~mellon/ "Angels can fly because they take themselves lightly" - G.K.Chesterton