question about an array of enum

Karl Botts kdb at chinet.chi.il.us
Thu Nov 8 13:50:37 AEST 1990


>>Can't happen.  "sizeof (char) == 1" is now fixed in the language, as
>>is the fact that it yields an integral type.
>
>What this really implies is that, if bit arrays are ever supported, they won't
>fit cleanly into the existing language and hence will probably not support all
>the same features as "normal" arrays.

I don't see how this follows.  Given the new fundamental type "bit" (a
keyword) then it does follow that:

main()
{
	bit	bits[1];
	printf("%d\n", sizeof(bits));
}

must print (at least) "1".  This is OK; sizeof produces the amount of
storage needed to hold an object, not the actual size of the object.
I would expect sizeof applied to an array of 8 bits to also return 1, tho
of course this would be implementation dependent.

Accessing elements of such an array would no doubt generate a little more
code, probably involving the use of a mask, than accessing an element of an
array of char; also, the address of an element of a bit array would likely
be wider than addresses of other objects.  But none of this is against the
rules.



More information about the Comp.std.c mailing list