stassen@trwspp.UUCP (09/11/84)
[] I just stumbled across bit fields in K & R. I've seen a lot of C code, and written a lot as well, but have never seen these used. It seems to be a useful feature of the language, yet there *must* be some good reason for not using bit fields... So, if you have the time, I would appreciate a note containing the answers to a short "survey" on bit fields. If there is enough interest, I will post the results - otherwise, I will mail results to anybody who asks for a copy. (1) Have you used bit fields? (a) Why or why not? (b) (If Yes) What have you used them for? (2) Where have you seen them used (in someone else's code)? Thanks for your time if you take it. If you want to flame me, please do so via private mail. ------------------------------------------------------------------------------ The opinions expressed in this document are my own. They are not intended to reflect the views of my employer - TRW - or anyone else. ------------------------------------------------------------------------------ Christian W. Stassen [decvax!trwrb,vortex,ihnp4!vortex]!trwspp!stassen "If we knew what the hell we were doing, then it wouldn't be research."
qwerty@drutx.UUCP (09/20/84)
We have used bit fields in dealing with hardware interfaces that are mapped into non-byte or non-word segments (ie. a couple of bits here, five bits there kind of things). They have turned out to be very useful. I have also used them as a form of compressed storage where I needed a lot of true/false states - you can get 16/32 to a word. There can be significant time wasted doing this if your underlying hardware does not support bit testing/manipulation.