【问题标题】:cannot acces struct ifreq无法访问结构 ifreq
【发布时间】:2014-09-16 08:30:15
【问题描述】:

我想使用 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

【问题讨论】:

标签: c linux gcc network-programming socket.io


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-27
    • 1970-01-01
    • 2014-06-20
    • 1970-01-01
    • 2017-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多