2.6 Incomplete Type

An identifier can be initially declared as having an incomplete type. An incomplete type declaration describes the object, but lacks the information needed to determine the object's size. For example, a declaration of an array of unknown size is an incomplete type declaration:

extern int x[];

The incomplete type may be completed in a subsequent declaration. Incomplete types are most commonly used when forward referencing arrays, structures, and unions. (Section 2.11 discusses forward references.) An object of an aggregate type cannot contain a member of an incomplete type; therefore, an aggregate object (a structure or array member) cannot contain itself, because the aggregate type is not complete until the end of its declaration. The following example shows how an incomplete structure type is declared and later completed:

struct s
  { struct t *pt };  /* Incomplete structure declaration  */
.
.
.
struct t
   { int a;
     float *ps };    /*  Completion of structure t        */

The void type is a special case of an incomplete type. It is an incomplete type that cannot be completed, and is used to signify that a function returns no value. Section 3.5 has more information on the void type.


Previous Page | Next Page | Table of Contents | Index