🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #382

Initialisation of unsigned strings

#382
From: eru
Date: Thu, 27 Jul 1989 17:56
23 lines
1735 bytes
I often use the "unsigned char" type to represent characters to avoid the
nonsense with negative letters (characters with the MSB set are commonly used
in ordinary text here). Thus sometimes arrays of "unsigned char" are initial-
ised with string constants. Then one day I compiled some such code with Gnu-C
with the switches -ansi -pedantic and it said that my initialisations are
non-ANSI.

First I thought that gcc was being too pedantic, but unfortunately the May
1988 draft seems to agree: 3.1.2.5 classifies "unsigned char" as an unsigned
integer type, and 3.5.7 says that an array of character type may be initialised
by a character string literal. Why could it not say "array of plain, signed or
unsigned char"?

Thus it appears that those who want to program in pure ANSI-C without the
fuzziness introduced by the implementation-dependent behaviour of plain char
lose the convenience of string literals. This ought to be changed in the
next version of the standard (if there ever is one). Prior art exists:
all the C-compilers with unsigned char that I have used compile this usage
of string literals.


Erkki Ruohtula    ! Nokia Telecommunications
eru@tele.nokia.fi ! P.O. Box 33 SF-02601 Espoo, Finland
Technical Details
Message-ID: <438@mjolner.tele.nokia.fi>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!mcvax!kth!draken!tut!santra!mjolner!tnvsu1.tele.nokia.fi!eru

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!mcvax!kth!draken!tut!santra!mjolner!tnvsu1.tele.nokia.fi!eru
From: eru@tnvsu1.tele.nokia.fi
Newsgroups: comp.std.c
Subject: Initialisation of unsigned strings
Keywords: unsigned char, initialisation, standard
Message-ID: <438@mjolner.tele.nokia.fi>
Date: 27 Jul 89 17:56:13 GMT
Sender: news@mjolner.tele.nokia.fi
Reply-To: eru@tnvsu1.tele.nokia.fi ()
Organization: Nokia Telecommunications
Lines: 23