“ctx”是什么意思?意思是?
我已经看到它在不同的库中作为缩写使用了两次,但我无法理解它的含义。
例如这里:
static int reformat_string(void * ctx, const unsigned char * stringVal,
size_t stringLen)
{
yajl_gen g = (yajl_gen) ctx;
return yajl_gen_status_ok == yajl_gen_string(g, stringVal, stringLen);
}
据我所知,它通常用于结构。
I have seen it used twice already in different libraries as an abbreviation, but I can't wrap my head around what it should mean.
For example here:
static int reformat_string(void * ctx, const unsigned char * stringVal,
size_t stringLen)
{
yajl_gen g = (yajl_gen) ctx;
return yajl_gen_status_ok == yajl_gen_string(g, stringVal, stringLen);
}
As far as I can tell, it is usually used for structs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它通常代表“上下文”。通常,这是传递给库中函数的某种结构,用于维护状态(即 context< /a> 函数调用)。
它是使用全局变量的更好替代方案。
It typically stands for "context". Usually this is some structure that gets passed around to functions in a library, used to maintain state (i.e., the context of the function call).
It's a preferable alternative to using global variables.