Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site fortune.UUCP
Path: utzoo!watmath!clyde!cbosgd!ihnp4!fortune!robert
From: robert@fortune.UUCP (Robert Clark)
Newsgroups: net.lang.c
Subject: Re: HARRIS FLAME Re: SHORT vs. INT
Message-ID: <5569@fortune.UUCP>
Date: Fri, 20-Sep-85 13:20:46 EDT
Article-I.D.: fortune.5569
Posted: Fri Sep 20 13:20:46 1985
Date-Received: Sat, 21-Sep-85 04:51:30 EDT
References: <1390@brl-tgr.ARPA> <2778@sun.uucp> <519@lasspvax.UUCP> <2803@sun.uucp>
Reply-To: robert@fortune.UUCP (Robert Clark)
Organization: Fortune Systems, Redwood City, CA
Lines: 34

In article <2803@sun.uucp> (Guy Harris) writes:
>> >People who use the C language should be sufficiently expert that they
>> >understand that "long" and "short" should not be selected in favor of "int"
>> >only if they are of different sizes on the machine you're coding on.
>> 
>>     But I can't quite fiqure out what you mean here.  Does it mean that is
>>   if 'short' 'int' and 'long' are the same size then I should choose
>>   something other than 'int'?
>
>You did figure out what I meant - that is exactly what I mean!  If you want
>to have a variable that can hold values outside the range -32767 to 32767,
>use "long", regardless of whether something else just might happen to work.
>It won't work on other machines, and unless you can guarantee that the code
>will *never* be run on another machine, you shouldn't do it.

If one is very concerned about portability to other-wordlength machines, why
not use typdefs like:

		typedef int bit16;
		typedef long bit32;

Then make all your declarations as bit16, bit32, etc.  Then when you want to
port to a machine with 7 bit shorts, 14 bit ints and 35 bit longs :-), just
change all the typedefs to  "typedef long bit16", etc....

I can see not liking the way this would make the code look, but it would 
certainly help with portability, and could make a big difference in final
process size if there are large arrays, etc.

Robert Clark

UUCP:	{sri-unix, amd, hpda, harpo, ihnp4, allegra}!fortune!robert
DDD:	(415) 594-2822
USPS:	Fortune Systems Corp, 101 Twin Dolphin Pkwy, Redwood Shores, CA 94065