我知道其他人发布了相同的错误,但是我找不到类似于我的任何内容。我尝试过实施一些解决方案,但无法弄清楚它为什么不起作用。为什么警告:从不兼容的指针类型进行赋值?
struct list_elem {
int value;
struct list *prev;
struct list *next;
};
struct list{
struct list_elem *header;
struct list_elem *footer;
};
struct list_elem *list_elem_malloc(void) {
struct list_elem *elem;
elem = malloc(sizeof(struct list_elem));
return elem;
}
void list_init(struct list *list) {
list->header = list_elem_malloc();
list->footer = list_elem_malloc();
list->header->prev = NULL;
list->footer->next = NULL;
list->header->next = list->footer; //ERROR on this line
list->footer->prev = list->header; //same ERROR on this line
}
为什么错误?
我在struct list_elem中犯了一个错字,prev和next应该是list_elems,而不是列表!!!!傻我。
Indeeed,我typo'd! ..谢谢你肯定没有看到:) – cxzp