Declaration puzzler (another old question?)

Doug Gwyn gwyn at smoke.ARPA
Wed Oct 5 15:15:40 AEST 1988


In article <30091 at oliveb.olivetti.com> chase at orc.olivetti.com (David Chase) writes:
>I can't figure out how to declare the type of an array with (say) 10
>elements, each of which is that array type.

You can't.  A C type cannot contain itself (although it CAN contain
pointers to instances of itself, under some circumstances).

>This is all a little puzzling to me.  If I didn't know that C was
>wonderful, I might think that arrays were a second-class type.

Arrays ARE second-class citizens in C.  This is quite well known.

However, the problem is that you're trying to do two things in
one declaration.  Use two declarations, the first for an
incomplete type and the second using that incomplete type to
help define a complete type of the desired shape.
You will have to resign yourself to using structures for this,
since a type has to be ultimately expressable in terms of basic
types, bit fields, etc. or pointers to structures.

Are you sure you really need a type like that?



More information about the Comp.lang.c mailing list