本文介绍了转换为函数指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了下面显示的代码行.

I have come across the line of code shown below.

我认为这可能是转换为返回void并采用void指针的函数指针.正确吗?

I think it may be a cast to a function pointer that returns void and takes a void pointer. Is that correct?

(void (*)(void *))SGENT_1_calc

推荐答案

是的,这是正确的.我发现它不是很可读,所以我建议声明要指出的功能的签名:

Yes, it is correct. I find that not very readable, so I suggest declaring the signature of the function to be pointed:

 typedef void sigrout_t(void*);

稍后我在投射,也许可以这样称呼

Later on I am casting, perhaps to call it like

 ((sigrout_t*) SGENT_1_calc) (someptr);

这篇关于转换为函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 17:00