Path: utzoo!attcan!uunet!mcsun!hp4nl!utrcu1!mi1!klamer From: klamer@mi.eltn.utwente.nl (Klamer Schutte -- Universiteit Twente) Newsgroups: comp.os.minix Subject: Re: use only short and long (not int) in struct message Message-ID: Date: 9 Jan 91 12:59:29 GMT References: <41145@nigel.ee.udel.edu> Sender: news@utrcu1.UUCP Lines: 46 burgess%creek.decnet@hqhsd.brooks.af.mil (CREEK::BURGESS) writes: >Klamer Schutte -- Universiteit Twente writes: >> >> >>Why include the assumption that short == 16 bits and long == 32 bits? >>Please use something like int16 and int32 when you mean that. >>This will save you when using a machine where short=16, int=32 and long=64 bits >> >>These names should be typedef'ed somewhere. >> >>Comments? > Wasn't the original definition of "short" and "long" from K&R explicit? I No! >recall a page in the book describing the various lengths of the the types and >"int" being the only machine-specific one. I think the definition was >short: 8 bits and long: [16||32) i can't remember exactly)] bits. Besides, >the compilers in question are virtually all written by and maintained by >people on the net. If short is always eight bits and long is always 32 bits, short 8 bits ??? >then the idea (IMHO) is an excellent method to overcome the problems with >variant "int" sizes. #ifdef QUOTE_ON K&R, edition 1 (No ansi C!), ISBN 0-13-110163-3, 1978, page 34: DEC PDP-11 Honeywell 6000 (more machines) char 8 bits 9 bits 8 bits int 16 bits 36 bits 32 bits short 16 bits 36 bits 16 bits long 32 bits 36 bits 32 bits The intent is that short and long should provide different lengths of integers where practical; int will normally reflect the most "natural" size for a particular machine. As you can see, each compiler is free to interpret short and long as appropriate for its own hardware. About all you should count on is that short is no longer than long #endif /* QUOTE_ON*/ I thus interpret the choice of short=16, int=32 and long=64 bits as legal. (IMHO) Hey ansi guru's, what's new? Klamer -- Klamer Schutte Faculty of electrical engineering -- University of Twente, The Netherlands klamer@mi.eltn.utwente.nl {backbone}!mcsun!utrcu1!utep!utelmi01!klamer