How to properly define a function pointer in struct, which takes struct as a pointer?

后端 未结 4 819
慢半拍i
慢半拍i 2021-01-05 00:56

I have a struct with a callback function, the callback function needs a pointer to the structure in order to do its operation. How do I properly define these elements such t

4条回答
  •  执念已碎
    2021-01-05 01:26

    something like this

    typedef struct _pr_PendingResponseItem_ {
    
        // some fields required for processing...
    
        int (*doAction)(struct _pr_PendingResponseItem_ *pr);
    } pr_PendingResponseItem;
    

    should fix it.

    (Tested & works)

提交回复
热议问题