无法访问结构 ifreq

标签 c linux gcc network-programming socket.io

我想使用 struct ifreq,但当我执行以下操作时无法访问它: 代码是:

  1 #include <sys/types.h>
  2 #include <sys/ioctl.h>
  3 #include <sys/socket.h>
  4 #include <net/if.h>
  5 #include <stdio.h>
  6 #include <stdlib.h>
  7 #include <unistd.h>
  8 #include <netdb.h>
  9 #include <string.h>
 10 #include <fcntl.h>
 11 #include <string.h>
 12 
 13 typedef uint32_t uint32;
 14 #define MAX_IF 10
 15 int
 16 main()
 17 {
 18     
 19         struct ifreq ifVec[MAX_IF];
 20 
 21         int sock = -1;

当我制作时,出现一些错误:

windeal@ubuntu:~/Windeal/apue$ make
gcc "-std=c99" -o getIfInfo.o -c getIfInfo.c
getIfInfo.c: In function ‘main’:
getIfInfo.c:18:15: error: array type has incomplete element type

最佳答案

如上所述here ,编译时应该使用-std=gnu99而不是-std=c99

关于无法访问结构 ifreq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25864032/

相关文章:

linux - 使用 cron 作业将磁盘空间信息转为带有日期的 csv

c - i386 GNU ld : file not recognized: File format not recognized

C-X11 API : Custom Control Redraw Issue

c - GCC#define 语句字节顺序错误

C:缓冲区溢出,更改传递的变量

c++ - accept后如何判断正在使用的IP地址?

linux - Pre Ptrace linux gdb 断点是如何工作的?

c - 在 Solaris 5.10 上使用集群()

c - Scanf 正在获取垃圾文件

c - linux下的C语言正常运行时间