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)));
這樣就沒有警告了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM