此error出现的原因是因为函数参数引用不正确,a 与b 两者类型不匹配。
关于此问题,根本原因是因为指针概念不清晰。
以下是头文件DLList.h节选:
typedef struct DLListNode {
int value; // value of this list item (int)
struct DLListNode *prev;
// pointer previous node in list
struct DLListNode *next;
// pointer to next node in list
} DLListNode;
typedef struct DLListNode *DLListNodeP;
typedef struct DLListRep {
int nitems; // count of items in list
DLListNode *first; // first node in list
DLListNode *curr; // current node in list
DLListNode *last; // last node in list
} DLListRep;
typedef struct DLListRep *DLList;
/* creates a new DLListNode, with a given val*/
DLListNode *newDLListNode(int val);
// create a new empty DLList
DLList newDLList();
其中,
typedef struct DLListNode *DLListNodeP;
*号跟在类型的后边表示声明或者定义的是指针,在变量前面是解引用符、
此处表示有一个名叫DLListNodeP的指针,类型为DLListNode。
若要引用头文件中的函数,正确写法应为:
DLListNodeP m =newDLListNode(p->value);
AddListNode_back(peaksL,m);
void AddListNode_back(DLList pList, DLListNodeP pNode)
通过DLListNodeP与DLList两个指针来操作。