What's wrong with linux/if.h and net/if.h?

Discussion in 'C++' started by fish, Jan 6, 2012.

  1. fish

    fish Guest

    In my project, I include pfring.h, but compile error: some functions
    in net/if.h and linux/if.h are redefinition. I found that the pfring.h
    include linux/if.h So, I test a program, my test code:

    #include <linux/if.h>
    #include <net/if.h>

    int main(void) {
    return 0;
    }
    It expected compile error. So, what's wrong with linux/if.h and net/
    if.h ? Can not I include them at once?

    error message:
    ===========================
    In file included from test.c:1:0:
    /usr/include/linux/if.h:178:19: error: field 'ifru_addr' has
    incomplete type
    /usr/include/linux/if.h:179:19: error: field 'ifru_dstaddr' has
    incomplete type
    /usr/include/linux/if.h:180:19: error: field 'ifru_broadaddr' has
    incomplete type
    /usr/include/linux/if.h:181:19: error: field 'ifru_netmask' has
    incomplete type
    /usr/include/linux/if.h:182:20: error: field 'ifru_hwaddr' has
    incomplete type
    In file included from test.c:2:0:
    /usr/include/net/if.h:45:5: error: expected identifier before numeric
    constant
    /usr/include/net/if.h:112:8: error: redefinition of 'struct ifmap'
    /usr/include/linux/if.h:136:8: note: originally defined here
    /usr/include/net/if.h:127:8: error: redefinition of 'struct ifreq'
    /usr/include/linux/if.h:170:8: note: originally defined here
    /usr/include/net/if.h:177:8: error: redefinition of 'struct ifconf'
    /usr/include/linux/if.h:219:8: note: originally defined here
     
    fish, Jan 6, 2012
    #1
    1. Advertising

  2. fish

    Jorgen Grahn Guest

    On Fri, 2012-01-06, fish wrote:
    > In my project, I include pfring.h, but compile error: some functions
    > in net/if.h and linux/if.h are redefinition. I found that the pfring.h
    > include linux/if.h So, I test a program, my test code:

    ....

    Wrong group; try comp.os.linux.networking or
    comp.os.linux.development.system.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Jan 6, 2012
    #2
    1. Advertising

  3. fish

    Ian Collins Guest

    On 01/ 6/12 09:11 PM, fish wrote:
    > In my project, I include pfring.h, but compile error: some functions
    > in net/if.h and linux/if.h are redefinition. I found that the pfring.h
    > include linux/if.h So, I test a program, my test code:
    >
    > #include<linux/if.h>
    > #include<net/if.h>


    You really should ask this on a Linux programming group.

    --
    Ian Collins
     
    Ian Collins, Jan 6, 2012
    #3
  4. fish

    Goran Guest

    On Jan 6, 9:11 am, fish <> wrote:
    > In my project, I include pfring.h, but compile error: some functions
    > in net/if.h and linux/if.h are redefinition. I found that the pfring.h
    > include linux/if.h So, I test a program, my test code:
    >
    > #include <linux/if.h>
    > #include <net/if.h>
    >
    > int main(void) {
    >     return 0;}
    >
    > It expected compile error. So, what's wrong with linux/if.h and net/
    > if.h ? Can not I include them at once?
    >
    > error message:
    > ===========================
    > In file included from test.c:1:0:
    > /usr/include/linux/if.h:178:19: error: field 'ifru_addr' has
    > incomplete type


    Off the top of my head.. ifru_addr is sockaddr, so try including sys/
    socket.h (sockaddr should be defined there) before linux/if.h

    If that's your problem, then I'd say that linux/if.h is broken. You
    should be able to include it anywhere and expect stuff to work.

    Goran.
     
    Goran, Jan 6, 2012
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandr Molochnikov

    SystemColor in Linux - what's wrong?

    Alexandr Molochnikov, Jul 30, 2003, in forum: Java
    Replies:
    0
    Views:
    460
    Alexandr Molochnikov
    Jul 30, 2003
  2. Bernd Eggink

    Wrong default encoding on Linux

    Bernd Eggink, Sep 30, 2003, in forum: Java
    Replies:
    4
    Views:
    16,451
    Bernd Eggink
    Oct 3, 2003
  3. Matthew
    Replies:
    7
    Views:
    673
    Priscilla Walmsley
    Jan 7, 2005
  4. Ka
    Replies:
    10
    Views:
    695
    Richard Bos
    Jul 31, 2003
  5. Benedict Verheyen
    Replies:
    0
    Views:
    185
    Benedict Verheyen
    Jan 20, 2012
Loading...

Share This Page