Path: utzoo!mnetor!uunet!husc6!m2c!ulowell!cg-atla!duane From: duane@cg-atla.UUCP (Andrew Duane X5993) Newsgroups: comp.lang.c Subject: Re: Common ansi violation, exemplified. Message-ID: <3323@cg-atla.UUCP> Date: 20 Apr 88 12:45:11 GMT References: <10949@mimsy.UUCP> <1525@dataio.Data-IO.COM> <122@gannet.cl.cam.ac.uk> Organization: Compugraphic Corp., Wilmington, Mass Lines: 35 Summary: param.h In article <122@gannet.cl.cam.ac.uk>, am@jenny (Alan Mycroft) writes: > In article <1988Apr13.163235.420@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: > >> #elif (1<<63) < 0 > >> #define int_size_in_bits 64 > >Furthermore, even > >ignoring that, there is another problem: the result of shifting ***beyond*** > >the available number of bits is implementation-defined (or undefined). > There is a related problem in lesser shifts in that the ANSI draft forbids > 1<<31 even when ints have 32 bits (overflow) > Note that > 1U<<31 has to be used instead. 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): /* * Fundamental constants of the implementation. */ #define NBBY 8 /* number of bits in a byte */ #define NBPW sizeof(int) /* number of bytes in an integer */ If what you are after is a define for the number of bytes in an integer, why not try: #define int_size_in_bits (NBBY*NBPW) Andrew L. Duane (JOT-7) w:(617)-658-5600 X5993 h:(603)-434-7934 Compugraphic Corp. decvax!cg-atla!duane 200 Ballardvale St. ulowell/ \laidback Wilmington, Mass. 01887 cbosgd!ima/ \cgeuro Mail Stop 200II-3-5S ism780c/ \wizvax Only my cat shares my opinions, and she doesn't care how many bits are in a byte, just how many bits are in her food dish.