编译程序的时候出错.类型不能强制转换.解决办法
编译程序的时候出错.类型不能强制转换..
const u_char *packet_content;
struct ether_header *ethernet_protocol;
struct ether_header
{
u_int8_t ether_dhost[6];
u_int8_t ether_shost[6];
u_int16_t ether_type;
};
protocol_header = (struct ether_header*)packet_content;
编译的时候报错,这是报错信息.
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct CWGetEthernetDoc::ether_header *' (or there is no acceptable conversion)
求救.
------解决方案--------------------
你的protocol_header好像不是指针
如果不是指针的话,应该这样写
protocol_header = *(struct ether_header*)packet_content;
只有protocol_header为指针的时候,才能进行类型转换
const u_char *packet_content;
struct ether_header *ethernet_protocol;
struct ether_header
{
u_int8_t ether_dhost[6];
u_int8_t ether_shost[6];
u_int16_t ether_type;
};
protocol_header = (struct ether_header*)packet_content;
编译的时候报错,这是报错信息.
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct CWGetEthernetDoc::ether_header *' (or there is no acceptable conversion)
求救.
------解决方案--------------------
你的protocol_header好像不是指针
如果不是指针的话,应该这样写
protocol_header = *(struct ether_header*)packet_content;
只有protocol_header为指针的时候,才能进行类型转换