Cast to function pointer

后端 未结 3 1959
北海茫月
北海茫月 2020-12-28 14:12

I have come across the line of code shown below.

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

3条回答
  •  鱼传尺愫
    2020-12-28 14:27

    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*);
    

    I also have the coding convention that types ending with rout_t are such types for functions signatures. You might name it otherwise, since _t is a suffix reserved by POSIX.

    Later on I am casting, perhaps to call it like

     ((sigrout_t*) SGENT_1_calc) (someptr);
    

提交回复
热议问题