array of bits field
Karl Heuer
karl at haddock.ima.isc.com
Fri Feb 16 09:15:42 AEST 1990
In article <486 at sixhub.UUCP> davidsen at 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 at ima.isc.com or harvard!ima!karl), The Walking Lint
More information about the Comp.lang.c
mailing list