Linked Lists in C. error: conflicting types. Solution?

本秂侑毒 提交于 2019-12-12 01:43:23

问题


i have the following struct defined:

typedef struct PList{
    Person person;
    struct PList *nextPerson;  //  set to NULL by default <<<<<
}PList;

and this method:

int length(struct PList* db){
    PList* cur = db;
    int size = 0;
    while (cur != NULL){
    ++size;
    cur = cur->nextPerson;
}
    return size;
}

error: conflicting types for 'length' is being thrown at the signature for the length method.

Any ideas?


回答1:


That actually means that there is another function/declaration called length elsewhere in your source code structure that has a different function signature.

Find where length() function is defined, and pass correct structure objects to that function(either of type struct PList or PList*)



来源:https://stackoverflow.com/questions/13609875/linked-lists-in-c-error-conflicting-types-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!