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

F

fish

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
 
J

Jorgen Grahn

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
 
I

Ian Collins

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.
 
G

Goran

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top