首页 > 代码库 > Implicit declaration of function 'ether_ntoa' is invalid in C99

Implicit declaration of function 'ether_ntoa' is invalid in C99

报错代码:strcpy(temp, (char *)ether_ntoa(LLADDR(sdl)));解决方法:导入这三个头文件即可,#include <sys/types.h>#include <sys/socket.h>#include <net/ethernet.h>然后上面那行代码会有一个警告:"Incompatible pointer types passing ‘caddr_t‘ (aka ‘char *‘) to parameter of type ‘const struct ether_addr *‘" ;可以在LLADDR的前面加上(const struct ether_addr *) 也就是这样:
strcpy(temp, (
char *)ether_ntoa((const struct ether_addr *)LLADDR(sdl)));
这样就没有警告了。

 

Implicit declaration of function 'ether_ntoa' is invalid in C99