Date: 4 Jun 1997 12:45:24 -0000 From: mark thompson <thompson@squirrel.tgsoft.com> To: un_x@anchorage.net Cc: hackers@FreeBSD.ORG Subject: Re: signed/unsigned cpp Message-ID: <19970604124524.945.qmail@squirrel.tgsoft.com> In-Reply-To: message from Steve Howe on Mon, 2 Jun 1997 21:40:41 -0800 (AKDT)
next in thread | raw e-mail | index | archive | help
From: Steve Howe <un_x@anchorage.net> Date: Mon, 2 Jun 1997 21:40:41 -0800 (AKDT) On Tue, 3 Jun 1997, David Nugent wrote: > > It isn't only a portability issue, but also a c++ standards issue. > c++ distinguishes between these three types. Ansi c only has two > and there it *is* a portability issue as to whether char* is signed > or unsigned. This is one of the many ambiguities that c++ has the > luxury to resolve. :) i hate to carry on anything trivial ... but, Agreed. having a "default signedness" seems like trouble to me. when you are writing code, you should have some intentions for a signedness. imho, c++ should've just kept 2 types of signedness and made sure one or the other was always specified - then you wouldn't have the kludge of "whatever some other compiler deems it to be". i can't imagine a worthwhile use of that. It is a carryover from C. The rule in C was that each base type was defined to be whatever was "natural" on the underlying machine. Some machines only have native instructions for one type of char or another. (The unsupported flavor would require two or more instructions). Hence, C did not specify which type you would get by default. Neither does C++. But ANSI at least added the rigor of allowing you to specify which one you needed, and considering the misuse of the types as a portability issue. 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. Or if you only store characters and compare them for equality. but i have been wrong before :) Hmmm... -mark
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970604124524.945.qmail>