Warning when using function pointers in C

This is actually a non-critical question, but I get this warning most of the time I use function pointers and still couldn't figure out why on my own. Consider the following prototype: typedef void * Pointer; void tree_destroyLineage(Tree greatest_parent, void *dataDestructor(Pointer data)); And so far I can compile my thousand-line-long code and get zero warnings. So I'm assuming I wrote the declaration correctly. But then I call it in code, passing free as my destructor, since the data stored in the tree nodes are simple structs: tree_destroyLineage(decision_tree, free); And this makes me get a `"warning: passing argument 2 of 'tree_destroyLineage' from incompatible pointer type"` message. My first hypotesis was that the compiler couldn't figure out at compile time that `Pointer` and `void *` are the same thing, so I tried both creating another function with the exact same types of the function pointer that "repasses" the call to `free()` and changing the function pointer declaration to accept a `void *` instead of a Pointer. Both approaches gave me the very same warning at the very same place. What am I doing wrong and how do I solve it?

以上就是Warning when using function pointers in C的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏