Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Of Standards and Inventions: A Cautionary Tale Message-ID: <868@cresswell.quintus.UUCP> Date: 12 Apr 88 06:23:59 GMT References: <10949@mimsy.UUCP> <1525@dataio.Data-IO.COM> <7637@brl-smoke.ARPA> <10353@steinmetz.ge.com> Organization: Quintus Computer Systems, Mountain View, CA Lines: 30 In article <10353@steinmetz.ge.com>, davidsen@steinmetz.ge.com (William E. Davidsen Jr) writes: > With programs traveling > between 32 bit machines and 16 bit machines (286, 11s) I want to say: > #if sizeof int < 32 > #define INT long > #else > #define INT int > #endif I haven't got a copy of the latest dpANS (~ $70 in California). For the specific case of discerning the word-length of a machine known to be 2s- complement, would #if (1<<1) < 0 #define int_size_in_bits 2 ... #elif (1<<15) < 0 #define int_size_in_bits 16 ... #elif (1<<63) < 0 #define int_size_in_bits 64 #endif #if int_size_in_bits < 32 #define INT long #else #define INT int #endif do the job, or may the preprocessor and compiler interpret int constants differently? Better yet, the dpANS provides a file which has things like the size of various things in bits already defined in it.