Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!think!bloom-beacon!oberon!cit-vax!ucla-cs!zen!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: 32bit = 16bit x 16bit Message-ID: <8710170245.AA19969@cory.Berkeley.EDU> Date: Fri, 16-Oct-87 22:45:57 EDT Article-I.D.: cory.8710170245.AA19969 Posted: Fri Oct 16 22:45:57 1987 Date-Received: Sun, 18-Oct-87 08:47:45 EDT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 50 :>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. : This is all moot anyway. I would like to point out that even if you *do* use only char's short's and long's you can still get screwed up. Something like: short a,b; long c; c = a * b; Would yield a different result when run on a 32bit-int vs 16bit-int compiler. You aren't going to see me writing code like: c = (long)a * b with MY 32 bit compiler.... My source would become unreadable if I put in all that garbage to ensure it was compileable with 'any' C compiler. :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: True... but garbage. By the same reasons if I made the above assumptions when writing C, my source would become unreadable. Additionaly, it would take me months rather than weeks to complete large programming projects. This is from EXPERIENCE. There have been several occasions where I've had to write programs that would compile on both my Amiga and on a (ich) PC-XT ... and they took about twice as long to write than if for just one machine. In fact, other problems turn up that have nothing to do with standard C. How many of you assume you can fopen() a file and read it byte for byte with getc()??? Think again. But I DO make this assumption whenever I write programs for my Amiga. As far as I'm concerned, for any software I will ever write for the Amiga, integers are 32 bits, shorts are 16 bits, chars are 8 bits. If I start writing software for a CRAY in C, I would make different assumptions. Depending on the machine, my assumptions may be tight (Amiga, Vax), or loose (Cray). And if I ever have to port any of the stuff, tough on me! (or not so tough as the source would be extremely readable). -Matt