xcode 函数“ether_ntoa”的隐式声明在 C99 中无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11245280/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Implicit declaration of function 'ether_ntoa' is invalid in C99
提问by Orchid
It's part of a series of functions that retrieve IP & Mac addresses from the phone.
它是从电话中检索 IP 和 Mac 地址的一系列功能的一部分。
strcpy(temp, (char *)ether_ntoa((const struct ether_addr *)LLADDR(sdl)));
EDIT: No equivalent function needed, there were just a few missing headers.
编辑:不需要等效的功能,只是缺少一些标题。
EDIT: Added cast to LLADDR(sdl)
编辑:将演员表添加到 LLADDR(sdl)
回答by Phillip Mills
As I read it, the error message isn't claiming that the function is missing, only that you don't include its declaration. (I don't knowthat it exists, only that the message has a different complaint.)
当我读到它时,错误消息并没有声称该函数丢失了,只是您没有包含它的声明。(我不知道它是否存在,只知道该消息有不同的抱怨。)
In case it helps, man ether_ntoa
tells me:
如果有帮助,请man ether_ntoa
告诉我:
#include <sys/types.h>
#include <sys/socket.h>
#include <net/ethernet.h>
回答by rjobidon
I included following header file and source code compiled successfully:
我包含了以下头文件和成功编译的源代码:
#import <arpa/inet.h>