关于C语言函数指针赋值的问题
如下代码是一个公共的接口:
typedef struct tag_PHY_IF_CTL{
BOOLEAN* p_fd_state;
void* p_fd; //串口、网络都可以
UINT8** pp_error_str;
INT32(*p_PhyIfConnect)(void *);
INT32(*p_PhyIfRecv)(void *, UINT8 *buf, INT32 len);
INT32(*p_PhyIfSend)(void *, UINT8 *buf, INT32 len);
INT32(*p_PhyIfFlush)(void *);
INT32(*p_PhyIfClose)(void *);
}PHY_IF_CTL;
将以下一个结构体中的函数指针
#pragma pack(1)
typedef struct tag_UART_CTL{
//串口私有项
UINT8 uart_number;
UINT32 baudrate;
UINT8 databit;
UINT8 stopbit;
UINT8 parity;
UINT32 timeout_ms;
pthread_mutex_t *uart_mutex;
//物理接口项目(网口或串口)
BOOLEAN fd_state; //是否连接成功
#if defined __GNUC__
INT32 fd;
#elif defined _MSC_VER
HANDLE fd;
#endif
UINT8 *p_error_str;
INT32(*p_UartConnect)(struct tag_UART_CTL *p_uart_c);
INT32(*p_UartSend)(struct tag_UART_CTL *p_uart_c, UINT8 *buf, INT32 len);
INT32(*p_UartRecv)(struct tag_UART_CTL *p_uart_c, UINT8 *buf, INT32 len);
INT32(*p_UartFlush)(struct tag_UART_CTL *p_uart_c);
INT32(*p_UartClose)(struct tag_UART_CTL *p_uart_c);
}UART_CTL;
如下图赋值时
p_3761_c->phy_if_c.p_PhyIfConnect = p_uart_c->p_UartConnect;
p_3761_c->phy_if_c.p_PhyIfSend = p_uart_c->p_UartSend;
p_3761_c->phy_if_c.p_PhyIfRecv = p_uart_c->p_UartRecv;
p_3761_c->phy_if_c.p_PhyIfClose = p_uart_c->p_UartClose;
p_3761_c->phy_if_c.p_PhyIfFlush = p_uart_c->p_UartFlush;
gcc会报warning: assignment from incompatible pointer type这个警告
是不是我PHY_IF_CTL中函数指针参数void* 与 UART_CTL中struct tag_UART_CTL 类型不匹配,求教下如何解决该问题?