有人可以向我解释这段代码有什么问题吗?
#include<stdio.h>
struct A{
int i;
struct A* parent;
struct B test; // error: field ‘test’ has incomplete type
};
struct B{
struct A* rootParent;
int ref;
int something;
};
int main(){
struct A some, some2;
some.i = 0;
some.parent = &some2;
some.test.rootParent = &some;
some.test.ref = some.test.something = 0;
some2.i =0;
some2.parent = 0;
some2.test.rootParent = 0;
some2.test.ref = some2.test.something = 0;
return 0;
}
看来我在这里缺少一些基本的东西。为什么 A 和 B 的顺序很重要?有没有可能让它变得无关紧要?
如果我改变减速顺序一切正常,B优先。