<分区>
在浏览 C 的 sqlite 文档时,我发现这是一个函数的参数,这是什么意思?
int (*callback)(void*,int,char**,char**);
标签 c
<分区>
在浏览 C 的 sqlite 文档时,我发现这是一个函数的参数,这是什么意思?
int (*callback)(void*,int,char**,char**);
最佳答案
这是一个的原型(prototype)function pointer 到 callback function .
因为它在另一个函数中用作参数,这意味着在函数中用作参数之前,需要在代码中的某处声明和定义实际函数。 IE。像这样:
//declaration - possibly defined in a header file, or at top of .c file where it is used
int __cdecl handlerFunction(void*,int,char**,char**);
//definition
int __cdecl handlerFunction(void *db,int element,char **data1,char **data2)
{
//code to handle some event that invokes this callback
return 0
}
关于有人可以解释这是什么意思吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58694144/