I tried to create a struct that holds a pointer to it's type:
#include <stdio.h>
struct test{
test* t;
};
int main(){
return 0;
}
while compiled with gcc, this code produced an error:
:5:2: error: unknown type name 'test'
but while compiled on g++ it went just fine.
So what I want to understand is:
1) What causes this difference? I thought that if gcc uses one-pass compilation and g++ uses multipass that could explain it, but as I understood, this is not true.
2) How can I avoid this error and define a struct with a pointer to it's own type? (I don't want to use a void* or use casting unless there is no other option)