我有以下代码:
typedef struct Folder{
void (**vtable)();
struct Set *ns;
}Folder;
Node *newFolder(char *n,struct Set *ns);
当我编译这个文件时,它给出:
passing argument to parameter 'ns' here
Node *newFolder(char *n,struct Set *ns);
这是我的测试单元:
void testFolderNrNodes(CuTest *tc) {
Node_reset();
Node* folder = newFolder("folder_to_test", SetNil());
CuAssertIntEquals(tc, 1, nrNodes(folder));
}
这给了我这个错误:
incompatible integer to pointer conversion passing 'int' to parameter of type
'struct Set *' [-Wint-conversion]
Node* folder = newFolder("folder_to_test", SetNil());
^~~~~~~~
我不明白问题出在哪里。它来自struct Set *ns
吗?为什么我会收到此消息:“不兼容的整数到指针转换,将 'int' 传递给 'struct Set * 类型的参数”
?
有人可以让我知道我做错了什么吗?
最佳答案
您的SetNil()
函数要么返回一个整数,要么在使用之前尚未声明(在这种情况下,编译器将假定它返回一个整数)。然而,newFolder()
希望其第二个参数是 struct Set *
。
关于c - 将参数传递给参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22119947/