Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!crowl From: crowl@cs.rochester.edu (Lawrence Crowl) Newsgroups: comp.lang.c,comp.sys.atari.st,comp.sys.amiga Subject: Re: 32bit = 16bit x 16bit Message-ID: <3294@sol.ARPA> Date: Fri, 16-Oct-87 11:18:50 EDT Article-I.D.: sol.3294 Posted: Fri Oct 16 11:18:50 1987 Date-Received: Sat, 17-Oct-87 20:42:48 EDT References: <1912@gryphon.CTS.COM> Reply-To: crowl@cs.rochester.edu (Lawrence Crowl) Organization: U of Rochester, CS Dept, Rochester, NY Lines: 24 Xref: mnetor comp.lang.c:4950 comp.sys.atari.st:5718 comp.sys.amiga:9516 In article <1912@gryphon.CTS.COM> mhatter@pnet02.CTS.COM (Patrick E. Hughes) writes: >I might suggest one thing if you plan on porting many C programs: Don't Use >Ints. Use char, use long, use float, and since they don't change size you're >always set. Ints, as I've seen, are consistently inconsistent. NO! Char, short, and long do change size. The only thing you can rely on is that sizeof char <= sizeof short <= sizeof int <= sizeof long. If you want portable programs, DO NOT USE BASIC TYPES. At the top of the program, define a set of typedefs from program specific types to the basic types. For example: typedef char autos_t ; /* for number of automobiles owned by a person */ /* expected range 0 .. 20 */ typedef int potatoes_t ; /* for number of potatoes eaten by a city */ /* expected range 0 .. 80,000,000 */ Because the size of every program type can be changed in exactly one place in the source, this approach provides two major advantages. First, it is portable from one machine to another, and second, it allows the program to adapt to changing needs or improper design decisions. -- Lawrence Crowl 716-275-9499 University of Rochester crowl@cs.rochester.edu Computer Science Department ...!{allegra,decvax,rutgers}!rochester!crowl Rochester, New York, 14627