Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jun 1997 16:56:31 +0300
From:      Anatoly Vorobey <mellon@pobox.com>
To:        mark thompson <thompson@squirrel.tgsoft.com>
Cc:        hackers@freebsd.org
Subject:   Re: signed/unsigned cpp
Message-ID:  <19970604165631.47148@techunix.technion.ac.il>
References:  <19970604124524.945.qmail@squirrel.tgsoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



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