誰かがこのコードの何が問題なのか説明してもらえますか?
#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を使用します。