C 使用结构时获取不兼容的指针类型错误

C 使用结构时获取不兼容的指针类型错误,c,pointers,struct,C,Pointers,Struct,我正在写一个程序,在这个程序中,我必须创建一个员工列表,并处理其中的信息。在writeToFile中,我写入信息。到.txt文件。在newList中,我应该创建一个新列表,其中包含符合特定标准的员工。但是,当我初始化*newListHead指针时,我从不兼容的指针类型列表*{aka'struct newEmployeeList*}[-Wincompatible指针类型]中得到初始化'newEmployeeList*{aka'struct newEmployeeList*}错误。既然我对头指针做了

我正在写一个程序,在这个程序中,我必须创建一个员工列表,并处理其中的信息。在
writeToFile
中,我写入信息。到
.txt
文件。在
newList
中,我应该创建一个新列表,其中包含符合特定标准的员工。但是,当我初始化
*newListHead
指针时,我从不兼容的指针类型列表*{aka'struct newEmployeeList*}[-Wincompatible指针类型]中得到
初始化'newEmployeeList*{aka'struct newEmployeeList*}错误。既然我对
指针做了相同的操作,那么我做错了什么

typedef struct employee {
    char name[20];
    double salary;
    char gender[10];
} employee;

typedef struct List {
    employee info;
    struct List *next;
} List;

typedef struct newEmployeeList {
    employee info;
    struct newEmployeeList *next;
} newEmployeeList;

List *create_new_node() {
    List *new_node = NULL;
    new_node = (List*)malloc(sizeof(List));
    new_node->next = NULL;
    return new_node;
};

int main()
{
    List *head = create_new_node();
    writeToFile("test.txt", head);

    newEmployeeList *newListHead = create_new_node();
    newList(head, newListHead);

    return 0;
}


正如错误消息所说,
create\u new\u node
函数返回一个
List*
,但您正在将该值分配给一个
newEmployeeList*
。这些类型不兼容


newListHead
的类型更改为
List*
,或者创建一个不同的函数,返回
newEmployeeList*
的新实例。我建议使用前者,因为没有理由根据您所展示的内容使用类型
newEmployeeList

为什么您有一个单独的
List
newEmployeeList
除了名称之外完全相同?
List
newEmployeeList
是两种不同的类型。两种类型都应该只有一种类型。只要去掉
newEmployeeList
类型并使用
List
替换它。我必须创建一个新的结构,因为这是教授的要求。我不能改变它@AKX@zaro新类型的结构,或现有结构的新实例?@dbush new list,将只包含某些employeesThank。没有新员工名单的原因是因为这是教授的要求。