int main()
{
// forward declaration
struct myStruct_st *mS; // Note that this will expand as "struct struct myStruct_st *mS which does not make any sense to me"
return 0;
}
// definition of myStruct_s
typedef struct myStruct_s
{
int x;
int y;
} myStruct_st;
I understand that myStruct_s is the structure that needs to be forward declared. I had this typo in my code which seemed to compile. I wonder how though. Does anyone know?
The local struct has nothing to do with the struct defined outside of
main(). Inmain()you (forward-)declare a struct, define a pointer to that struct and never define the struct. That’s perfectly OK. It so happens that you define a struct with the same name outsidemain().