I was digging into a 3rd party code base and found that it is apparently valid to declare a type as a pointer to an undefined struct. As a minimum working example, consider a C file test.c
containing nothing but:
typedef struct foo *bar;
What surprises me is that this file compiles without any problems using the command
gcc test.c -shared
Why does the compiler not complain about the struct foo not being declared anywhere?
My environment is Ubuntu 16.04 with gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609.