1

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"?

Duggs
  • 169
  • 1
  • 12

1 Answers1

1

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.

P.P
  • 117,907
  • 20
  • 175
  • 238
  • no man compiler is not giving error ..thats what i thought first – Duggs Sep 11 '13 at 06:49
  • 1
    Do you enforce the strict standard compliance? When I do `gcc -Wall -pedantic -std=c99 t.c`, I get `t.c:1:12: error: array size missing in ‘arr’ t.c:1:12: warning: ‘arr’ defined but not used [-Wunused-variable]`. gcc by default enables many extensions and may not satisfy for all requirements of C standard. With the above options, it'd produce better diagnostics. – P.P Sep 11 '13 at 06:56