Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在结构之间形成双向链接?我试图这样实现它:
typedef struct { int foo; b *b; } a; typedef struct { int bar; a *a; } b;
但是结构 a 不知道 b 是什么,因为它是在之后声明的。
尝试这个,
typedef struct a a; typedef struct b b; struct a { int foo; b *b; } ; struct b { int bar; a *a; } ;
当您需要引用其他可能尚未定义的结构时,请像这样进行声明,它应该可以工作:
typedef struct { int foo; struct b *b; } a; typedef struct { int bar; struct a *a; } b;