Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: array of bits field Message-ID: <15956@haddock.ima.isc.com> Date: 15 Feb 90 22:15:42 GMT References: <2802@cunixc.cc.columbia.edu> <22287@mimsy.umd.edu> <7184@arcturus> <11961@frog.UUCP> <1990Feb12.182517.10921@cubmol.bio.columbia.edu> <486@sixhub.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 17 In article <486@sixhub.UUCP> davidsen@sixhub.UUCP (bill davidsen) writes: >I don't know of a way to do it in standard C, and if it were added as >an extension I would expect the syntax to be > int bits:1[16]; I would expect "int bits[16]:1", since the declaration is saying that "bits[i]" has type "int :1". (Cf. "int (*p[N])()", etc.) >Perhaps in gcc, which seems to have everyone's favorite feature. The problem is that, in C, an array name in an rvalue context decays into a pointer, and due to the rule that sizeof(char) is 1, you can't have pointers to objects smaller than char. This doesn't mean the extension couldn't be implemented, just that it would take some forethought to decide which rules should be broken in the process. Karl W. Z. Heuer (karl@ima.isc.com or harvard!ima!karl), The Walking Lint