Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site amdcad.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!gatech!amdcad!sorensen
From: sorensen@amdcad.UUCP (Sorensen David)
Newsgroups: net.lang.c
Subject: bit fields in unions
Message-ID: <6136@amdcad.UUCP>
Date: Sun, 10-Nov-85 17:29:07 EST
Article-I.D.: amdcad.6136
Posted: Sun Nov 10 17:29:07 1985
Date-Received: Mon, 11-Nov-85 06:12:57 EST
Organization: AMDCAD, Sunnyvale, CA
Lines: 37


	I recently was writing a declaration for a LISP form which looks
something like this:

                    --------------------------------- 
		   |      14-bit integer             |
	---------------------------------------------
       | gc | tag1 |    either ^ or v                |
        ---------------------------------------------
		   | tag2 |   13-bit pointer         |
		    ---------------------------------

	The form is 16 bits wide, with tag1 selecting between the
14-bit integer or 13-bit pointer with another tag. Attempting to
write a C declaration for this:

struct form {
	unsigned int gc : 1;
	unsigned int tag1 : 1;
	union {
		unsigned int number : 14;
		struct {
			unsigned int tag2 : 1;
			unsigned int pointer : 13;
			} pval;
		} val;
	};

	resulted in a "bit-field outside of struct" error, where
number :14 was declared in the union.  I could not find any explicit
mention of bit-fields not being allowed in unions in K & R, but all
C compilers I have tried have not allowed them.  Does anyone know
of a C compiler that allows this?  Or does anyone know why this is not
allowed?

	Tim Olson
	Advanced Micro Devices