我可以在 C99 中这样做吗? ?
typedef struct dlNode {
dlNode* next, prev;
void* datum;
} dlNode;
const static dlNode head={
.next = &tail,
.prev = NULL,
.datum = NULL
};
const static dlNode tail={
.next = NULL,
.prev = &head,
.datum = NULL
};
没有这个我也可以让我的程序运行。这会很方便。
最佳答案
可以。您只需转发声明 tail
即可使其正常工作:
typedef struct dlNode {
struct dlNode* next;
struct dlNode* prev;
void* datum;
} dlNode;
const static dlNode tail;
const static dlNode head={
.next = &tail,
.prev = NULL,
.datum = NULL
};
const static dlNode tail={
.next = NULL,
.prev = &head,
.datum = NULL
};
关于c - 我可以使用常量结构进行循环引用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46289498/