Path: utzoo!mnetor!uunet!husc6!purdue!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Common ansi violation, exemplified. Message-ID: <11147@mimsy.UUCP> Date: 21 Apr 88 02:33:39 GMT References: <10949@mimsy.UUCP> <1525@dataio.Data-IO.COM> <122@gannet.cl.cam.ac.uk> <3323@cg-atla.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 37 [various quotations of various people defining int_size_in_bits deleted, but note that the original idea was to test the result in the preprocessor proper] In article <3323@cg-atla.UUCP> duane@cg-atla.UUCP (Andrew Duane X5993) writes: >Pardon me for coming in late, but hasn't anyone looked through >the system include files? In /usr/include/sys/param.h, I see >the defines (on a SUN3): >#define NBBY 8 /* number of bits in a byte */ >#define NBPW sizeof(int) /* number of bytes in an integer */ [so] >#define int_size_in_bits (NBBY*NBPW) sizeof() is prohibited in preprocessor arithmetic; hence, with this definition, #if int_size_in_bits <= 32 will not do anything useful. The macro in is not a violation of anything at all; use of the value produced by NBPW is merely restricted to the compiler proper. The Sun kernel has no occurrences of the form `#if ', and neither can anyone else write this. If you are content with doing this arithemetic outside the preprocessor, there is no problem, but somewhere back in the reference history, someone wanted to write #if int_size_in_bits <= 16 typedef long foo_t; #else typedef int foo_t; #endif /* or something like that */ -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris