Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ittatc!bunker!garys From: garys@bunker.UUCP (Gary M. Samuelson) Newsgroups: net.lang.c Subject: Re: problems with the C parser Message-ID: <1171@bunker.UUCP> Date: Fri, 30-May-86 10:29:04 EDT Article-I.D.: bunker.1171 Posted: Fri May 30 10:29:04 1986 Date-Received: Sat, 31-May-86 07:21:17 EDT References: <5072@topaz.RUTGERS.EDU> Reply-To: garys@bunker.UUCP (Gary M. Samuelson) Organization: Bunker Ramo, Trumbull Ct Lines: 36 Keywords: bitfield,structure,'%&#@* In article <5072@topaz.RUTGERS.EDU> brisco@topaz.UUCP writes: > typedef union { > int intfield; /* change the record name - keyword */ > struct bool{unsigned x[32]:1}; > } newtype; > Can anyone else compile the above structure declaration? No. You didn't read far enough: "In all implementations, there are no arrays of fields" K&R, p. 197 I tried typedef union { int intfield; struct bool {int x:1; }bit[32]; } newtype; But each bit takes up an entire unsigned, so the size of the above is 32 * sizeof (unsigned). I think you will have to choose from masks, or making each bit a separate field: typedef union { int intfield; struct bool { unsigned x0:1, x1:1, x2:1, x3:1, x4:1, x5:1, x6:1, x7:1, x8:1, x9:1, x10:1, x11:1, x12:1, x13:1, x14:1, x15:1, x16:1, x17:1, x18:1, x19:1, x20:1, x21:1, x22:1, x23:1, x24:1, x25:1, x26:1, x27:1, x28:1, x29:1, x30:1, x31:1; } } newtype; Gary Samuelson