[英]“expected primary-expression before” error when passing pointer to function
I'm currently working on code which utilizes an external library and here is part of what is given in the library: 我目前正在研究利用外部库的代码,这是该库中给出的内容的一部分:
typedef void (*func_start_t) (void *);
extern int create(func_start_t func, void *a);
I'm trying to call this with the following line of code (where foo is another function): 我正在尝试使用以下代码行(其中foo是另一个函数)来调用此代码:
create(func_start_t foo, *args);
However I keep getting an erro expected primary-expression before foo
. 但是我一直expected primary-expression before foo
得到一个错误的expected primary-expression before foo
。 What am I doing wrong? 我究竟做错了什么?
You are doing something wrong. 您做错了。 The func_start_t
in the call to the function is totally unnecessary (and incorrect). 对该func_start_t
的调用中的func_start_t
是完全不必要的(并且不正确)。 You should just write: 您应该只写:
create(foo, *args); //Assuming `args` is a pointer to a pointer
Just call this: 只需致电:
create(foo, *args);
I'm assuming foo
is a function defined as: 我假设foo
是一个定义为的函数:
void foo(void*) {/*....*/}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.