struct Figlio
{
char nome[256];
struct Genitore* padre;
struct Genitore* madre;
};
struct Genitore
{
char nome[256];
struct Figlio* progenie;
};
int main()
{
return 0;
}
I expected that the above code does not compile since struct Genitore is not declared before Figlio, so a forward declaration of Genitore (i.e., struct Genitore; on the top) was needed. Instead, in C, it compiles without any problem.
Instead, if I pass a not-yet declared struct pointer to a function, e.g.,
void f(struct st*);
struct st{};
it raises the following warning
Warning: ‘struct st’ declared inside parameter list will not be visible outside of this definition or declaration
So, I don't understand why these different behaviours and, especially, why forward declarations of struct Genitore; and struct st; respectively are not requested.