Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!oddjob!gargoyle!ihnp4!twitch!hoqax!twb From: twb@hoqax.UUCP (BEATTIE) Newsgroups: comp.lang.c Subject: Re: Standard int sizes Message-ID: <764@hoqax.UUCP> Date: Thu, 16-Apr-87 09:08:51 EST Article-I.D.: hoqax.764 Posted: Thu Apr 16 09:08:51 1987 Date-Received: Sun, 19-Apr-87 08:43:08 EST References: <6759@brl-adm.ARPA> <230@ems.UUCP> <170@vianet.UUCP> Organization: AT&T Bell Labs, Holmdel, NJ Lines: 28 Summary: use typedef not #define In article <170@vianet.UUCP>, devine@vianet.UUCP writes: > If you need to know exact sizes of types, you should define your > own types using the preprocessor or typedefs. That is, if you need > a 16 bit arithmetic type, use: > > If "machine has compiler that uses 16 bits for 'short'" > #define int16 short > > If "machine has compiler that uses 16 bits for 'int'" > #define int16 int It is not a good idea to use #define where you mean typedef. Think about the difference between: typedef int *INT_PTR; INT_PTR a, b; and #define INT_PTR int * INT_PTR a, b; The first defines a and b to be pointers to int ("int *a, *b"). The second defines a as pointer to int and b as int ("int *a, b"). Remember that #define is a string substitution and typedef defines a new type. Tom.