Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: comp.unix.wizards Subject: Re: bitfields: how to cast (int) into a bit field? Message-ID: <786@dg_rtp.UUCP> Date: Sat, 3-Jan-87 13:55:39 EST Article-I.D.: dg_rtp.786 Posted: Sat Jan 3 13:55:39 1987 Date-Received: Sat, 3-Jan-87 21:46:54 EST References: <844@sphinx.UChicago.UUCP> <4746@ism780c.UUCP> <4082@watmath.UUCP> Lines: 21 Summary: There is no way to cast (int) into a bit field. > idallen@watmath.UUCP > How does one cast an integer into, say, a 6-bit bit field in such a > manner that LINT won't complain "conversion may lose accuracy"? Since bit fields can only be uttered as structure members, and since only the trivial cast is available on structures, it is simply not possible to utter a cast of an int into a 6-bit field. There ARE ways of supressing lint's warnings, of course. One way is to cause the preprocessor to include the offending assignment only when compiling and not when typechecking. > How does one create a typedef for a bit field, such that one might use > it to perform the above cast? Again, it is simply not possible to have a "bit-field type" in C. -- The negative judgment is the peak of mentality. --- Alfred North Whitehead -- Wayne Throop!mcnc!rti-sel!dg_rtp!throopw