Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bbn!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: <3626@sol.ARPA> Date: Tue, 27-Oct-87 13:53:03 EST Article-I.D.: sol.3626 Posted: Tue Oct 27 13:53:03 1987 Date-Received: Thu, 29-Oct-87 23:46:36 EST References: <1912@gryphon.CTS.COM> <3294@sol.ARPA> <2545@cbmvax.UUCP> <2565@cbmvax.UUCP> <2262@sfsup.UUCP> Reply-To: crowl@cs.rochester.edu (Lawrence Crowl) Organization: U of Rochester, CS Dept, Rochester, NY Lines: 55 Xref: mnetor comp.lang.c:5172 comp.sys.atari.st:5965 comp.sys.amiga:10031 In article <2262@sfsup.UUCP> mpl@sfsup.UUCP (M.P.Lindner) writes: >3. as for the people who say "Never use the basic types", I say the following: > 1. use "char" to mean a character or a byte (guaranteed in K&R) Use char to mean a character. Use "typedef char applicationtype" when the best implementation for the intended use happens to be a char on your machine. My six bit char may not give the range you assumed because of your chars are twelve bits. > 2. use short for a small integer Use "typedef short applicationtype" when the best implementation for the intended use happens to be a short on your machine. My short may be longer than your short. This way I only have to change the implementation in one place. > 3. use int where the size doesn't matter Use "typedef int applicationtype" when the implementation for the intended use does not matter significantly. Let's hope my ints are at least as large as you assume. > 4. use long where you need a long (ie in interfacing to the OS, etc.) Use a crowbar where you need a crowbar? Use "typedef long systemtype" when the implementation for the system type is a long. When porting, changing the types passed to system routines in one place can reduce hassle considerably. > 5. use pointers with care Amen. > 6. use void where you mean void (either the compiler handles it or > it doesn't - if it does, great, if it doesn't, try "cc -Dvoid=int" > but don't go changing the input language because you have a bad > compiler. Agreed. > 7. NEVER NEVER NEVER! use LONG, ULONG, VOID, etc. > if you're using ULONG because you want an unsigned 32 bit integer > try using > typedef unsigned long uint32; > typedef long int32; > so someone can try to figure out what bizzare thing you were trying > to do. Use "typedef BASIC_TYPE APPLICATION_TYPE /* required range is a..b */". This documents the program's needs and allows people porting the program to identify exactly what changes need to be made. -- Lawrence Crowl 716-275-9499 University of Rochester crowl@cs.rochester.edu Computer Science Department ...!{allegra,decvax,rutgers}!rochester!crowl Rochester, New York, 14627