在功能调用中免费结构太多参数

free struct too many arguments in function call

本文关键字:结构 太多 参数 免费 功能 调用      更新时间:2023-10-16

我有一个列表结构:

typedef struct FaceNode{
    FaceNode *next;
    Face *aFace;
    FaceNode *prev; 
} FaceNode;

我将此结构用作成员:

FaceNode *myFaces;

并这样初始化(在构造函数中)

this->myFaces = (FaceNode*)malloc(sizeof(FaceNode)*1);

稍后我想如下释放它:

FaceNode *theCurrentFaceNode;
Face* theCurrentFace;
while(this->myFaces->next){
   theCurrentFaceNode = this->myFaces;
   theCurrentFace = theCurrentFaceNode->aFace;
   this->myFaces = this->myFaces->next;
   free(theCurrentFace);
   free(theCurrentFaceNode);
}

现在我的IDE告诉我:"错误,函数呼叫中的争论太多"。

这是怎么回事?

欢呼

您显然已经声明了自己的名为 free的函数,并且编译器发现,而不是您认为正在调用的函数。使用示波器分辨率操作员调用全局函数:

::free(theCurrentFace);

或找到其他free功能,并给它一个不同的名称。它可能是您要实施的班级的成员;也看班级的祖先课程。