Why chars unsigned on 3B?

Sam Kendall kendall at wjh12.UUCP
Mon Jun 11 05:59:03 AEST 1984


> Why do you care whether chars default to unsigned or signed?

I have gotten this question from several intelligent people; I guess the
answer isn't obvious as I thought it was.  There are two main reasons.

(1) I want chars to be signed because making them so provides 8-bit
    signed integers, not otherwise available through C on the 3B.  Some
    object that this type should not exist because it cannot be used
    portably.  But this type can be used portably through parameterization
    of code: 

	#if CHAR_SIGNED
	typedef char SMALLINT;
	#else
	typedef short SMALLINT;
	#endif

    or the like.

(2) Most UNIX machines have signed characters.  Porting is easier to a
    machine with signed characters also.  Sure, I am careful to avoid
    writing programs which depend on signed characters, other than as
    illustrated above; but I have to port other people's programs
    sometimes.  Idealism cannot escape that fact.

	Sam Kendall	{allegra,ihnp4,ima,amd70}!wjh12!kendall
	Delft Consulting Corp.	    decvax!genrad!wjh12!kendall



More information about the Comp.unix.wizards mailing list