无法访问struct ifreq

时间:2014-09-16 08:30:15

标签: 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

1 个答案:

答案 0 :(得分:0)

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

相关问题