c - 将参数传递给参数

标签 c dispatch

我有以下代码:

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/

相关文章:

c - 未显示 Mandelbrot 集

swift - 如何在异步迭代中设置DispatchGroup?

python - django中的调度用于什么?

swift - Swift 3 中通过间接调用调用了错误的专用泛型函数

c++ - 为什么在宏扩展之前完成 token 替换?

c - 队列字母无效

使用多个 main() 进行编译

c - 用 C 读取二进制文件的奇怪结果

objective-c - 在 Objective-C 中实现调度表 : how to declare an array of selectors

r - 关于 UseMethod 搜索机制的困惑