c - Cannot access ifreq structure definition, __USE_MISC macro undefined -


i trying compile following single c file (called main.c):

#include <stdio.h>  #define __use_misc 1 #include <net/if.h>  int main(int argc, char **argv) { ifreq id_ifreq; fprintf(stdout, ">>>>>> ok <<<<<<\n"); } 

... using "gcc main.c -o main". following error:

main.c: in function ‘main’: main.c:9:2: error: unknown type name ‘ifreq’ 

i know "ifreq" structure definition lies within "#ifdef __use_misc" macro, however, cannot activate block of code.

i developed following code checking macros defined (compiled "gcc main.c -o main"):

#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <net/if.h>  int main(int argc, char **argv) {     #ifdef __use_misc        printf("__use_misc defined\n");    #endif    #ifdef _gnu_source        printf("_gnu_source defined\n");    #endif     #ifdef _bsd_source        printf("_bsd_source defined\n");    #endif     #ifdef _svid_source        printf("_svid_source defined\n");    #endif  } 

the result defined "_gnu_source" one. however, still not capable of using definition of "ifreq" structure included in "net/if.h" file.

anybody can help?

you omitting struct keyword (in c, struct definition not typedef)

#include <stdio.h> #include <net/if.h>  int main(int argc, char **argv) { struct ifreq id_ifreq; fprintf(stdout, ">>>>>> ok <<<<<<\n"); return 0; } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -