Possible Duplicate:
undefined C struct forward declaration
How is it possible to declare a pointer to structure even when I do not declare a structure?
#include<stdio.h>
int main(){
struct s{
struct p *ptr;
};
}
Why does the above compile successfully?
It’s possible because the compiler doesn’t need to know anything about the structure if it only deals with a pointer to it.
This is a commonly used technique and is usually called an “opaque pointer”.