我的#include 文件损坏了吗?

asg*_*451 1 c linux ubuntu wifi

我一直在尝试使用 ioctl 来获取我的 wifi 连接状态,但遇到了一个问题:每当我这样做时#include <linux/wireless.h>,gcc 都会生成很多错误,例如

\n\n
/usr/include/linux/wireless.h:869:18: error: field \xe2\x80\x98src_addr\xe2\x80\x99 has incomplete type\nstruct sockaddr src_addr;\n                ^\n/usr/include/linux/wireless.h:880:18: error: field \xe2\x80\x98bssid\xe2\x80\x99 has incomplete type\nstruct sockaddr bssid;\n                ^\n
Run Code Online (Sandbox Code Playgroud)\n\n

还有更多类似的。这是什么意思?我该怎么办?我在虚拟机中运行 Ubuntu 14.04 有关系吗?

\n\n

如果有帮助的话,我的代码很简单:

\n\n
#include <linux/wireless.h>\nint main() { return 0; }\n
Run Code Online (Sandbox Code Playgroud)\n\n

我正在编译gcc thing.c

\n\n

谢谢。

\n

use*_*990 5

您需要包含 sockaddr。您必须包括:

  #include <netinet/in.h>
  #include <sys/socket.h>
Run Code Online (Sandbox Code Playgroud)