Duggs
Duggs

Reputation: 179

What is the meaning of statement below that the declared type shall not be incomplete type

The C standard states:

If the declaration of an identifier for an object is a tentative definition and has internal linkage, the declared type shall not be an incomplete type

What does it mean that "the declared type shall not be an incomplete type"?

Upvotes: 1

Views: 575

Answers (1)

P.P
P.P

Reputation: 121427

That means you are not allowed to have:

static int arr[]; // This is illegal as per the quoted standard.
int main(void) {}

The array arris tentatively defined and has an incomplete type (lacks information about the size of the object) and also has internal linkage (static says arr has internal linkage).

Whereas the following (at file scope),

int i; // i is tentatively defined. Valid.

int arr[]; // tentative definition & incomplete type. A further definition 
           // of arr can appear elsewhere. If not, it's treated like
           //  int arr[] = {0}; i.e. an array with 1 element.
           // Valid.

are valid.

Upvotes: 1

Related Questions