//local 宣告function pointer
int (*netcmd)(uint16,int(*)(cbuf_t*,uint16,void*,uint16),void*,uint16,void*,uint16*,uint32,int*);
//指定成不同的function pointer 根據傳入的參數
netcmd = (block) ? netcmdBlockSend : netcmdNonblockSend;
//可以直接call不需dereference 但是(*netcmd)才是比較一般的作法 參考這個網址
err_code=netcmd(
EVT_ARP_ADD, netexeArpAdd, &add, sizeof(cmdArpAdd_t),
NULL, NULL, 5000, &result);
一些介紹function pointer的link:
- Pointers to functions : 簡單有介紹state machine 用function pointer array的作法
- The function pointer tutorial : 還沒看過全部
沒有留言:
張貼留言