Windeal
Windeal

Reputation: 87

cannot acces struct ifreq

i want to use struct ifreq, but it cannot be access when i make: the code is :

  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;

when i make, there are some error :

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

Upvotes: 0

Views: 2848

Answers (1)

Filippo Lauria
Filippo Lauria

Reputation: 2064

As stated here, you should use -std=gnu99 instead of -std=c99 when compiling.

Upvotes: 1

Related Questions