C.中的链接列表错误:类型冲突.解决方案? [英] Linked Lists in C. error: conflicting types. Solution?

查看:119
本文介绍了C.中的链接列表错误:类型冲突.解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义了以下结构:

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

和此方法:

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

错误:length方法的签名处引发了"length"类型冲突.

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

有什么想法吗?

推荐答案

这实际上意味着在源代码结构中的其他地方,还有一个名为length的函数/声明,具有不同的函数签名.

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

查找定义了length()函数的位置,并将正确的结构对象传递给该函数(类型struct PListPList*)

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

这篇关于C.中的链接列表错误:类型冲突.解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆