From: Bill Godfrey Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Re: typedef'ing a 24-bit integer Date: Wed, 26 May 99 22:52:29 Message-ID: <19990526.68595010.14752@bacchae.demon.co.uk.228.60.172> References: <37459ABF DOT FF51CA41 AT aaual DOT ualg DOT pt> <927396955snz AT genesis DOT demon DOT co DOT uk> NNTP-Posting-Host: bacchae.demon.co.uk X-NNTP-Posting-Host: bacchae.demon.co.uk:212.228.60.172 X-Trace: news.demon.co.uk 927759119 nnrp-02:2887 NO-IDENT bacchae.demon.co.uk:212.228.60.172 X-Complaints-To: abuse AT demon DOT net Lines: 19 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com fred AT genesis DOT demon DOT co DOT uk (Lawrence Kirby) writes: > No type in C is guaranteed to occupy a specific amount of space in memory. > What C guarantees is minimum ranges for specific types. Bit-fields > act like specific width types but there are few guarantees about their > storage. Why do you need this anyway? Such a requirement usually > indicates a poor approach. (I can't speak for the original questioner, but...) Maybe to store a large array of integers each of which only requires 24 bits of range. To do this, I'd probably keep a malloc'd array of unsigned characters, and write a macro to take an index, extract [i*3] [i*3+1] and [i*3+2] and shove them into a long using << and | operators. What to do when CHAR_BIT != 8 is left as an excercise to the reader. Bill, bit flippingly.