Incomplete types oddity in C

Here's something odd from C. It's to do with incomplete types. This compiles fine in gcc:
typedef struct wibble wibble;
void f(wibble * ptr);
but this does not:
typedef struct wibble wibble;
void f(wibble array[]);
A bit of searching in the Standard reveals

6.7.5.3 Function declarators
paragraph 12 - If the function declarator is not part of a definition of that function, parameters may have incomplete types...

This suggests the [] based declarator is ok. However it's not because...

6.7.5.2 Array declarators
paragraph 1 - the element type shall not be an incomplete type

Which leads you ask what is an incomplete type?

6.2.5 Types
paragraph 22 - An array of unknown size is an incomplete type.

Which is interesting because it says nothing about an array of unknown type being an incomplete type. This is a shame. Particularly because of the new [] array declarator syntax in c99.

No comments:

Post a Comment