Hi, I use the libbridge and an other lib (libnl) in a same project. I include the headers files of the two lib (libnl first and libbridgge after) and I've a conflict with the inclusion of linux/if.h (in libnl headers) and net/if.h (in libbridge.h), I've this error : /usr/include/net/if.h:45: error: parse error before numeric constant /usr/include/net/if.h:111: error: redefinition of `struct ifmap' /usr/include/net/if.h:126: error: redefinition of `struct ifreq' /usr/include/net/if.h:176: error: redefinition of `struct ifconf' I modify the libbridge.h to include the net/if.h only if the linux/if.h is not define : --- libbridge.h 2007-11-22 12:16:17.000000000 +0100 +++ libbridge_modify.h 2007-11-22 12:15:58.000000000 +0100 @@ -19,7 +19,9 @@ #ifndef _LIBBRIDGE_H #define _LIBBRIDGE_H +#ifndef _LINUX_IF_H #include <net/if.h> +#endif #include <linux/if_bridge.h> struct bridge_id Do you think it's a good solution ? Doude.
I fixed the problem differently because I don't want more conditional compilation. The ideal fix would be to get glibc to the headers fixed to be compatible. Use linux/if.h rather than net/if.h for compatiablity with other headers. Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> --- libbridge/libbridge.h | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/libbridge/libbridge.h b/libbridge/libbridge.h index 20d5bb5..016acea 100644 --- a/libbridge/libbridge.h +++ b/libbridge/libbridge.h @@ -19,9 +19,15 @@ #ifndef _LIBBRIDGE_H #define _LIBBRIDGE_H -#include <net/if.h> +#include <sys/socket.h> +#include <linux/if.h> #include <linux/if_bridge.h> +/* defined in net/if.h but that conflicts with linux/if.h... */ +extern unsigned int if_nametoindex (const char *__ifname); +extern char *if_indextoname (unsigned int __ifindex, char *__ifname); + + struct bridge_id { unsigned char prio[2]; -- 1.5.3.4
Apparently Analagous Threads
- [Bridge] brctl uses incorrect sysfs path
- [Bridge] two fields are missing in brctl output when using /sys
- [Bridge] [PATCH] bridge-utils: Add 'hairpin' port forwarding mode
- [Bridge] [PATCH] bridge-utils: Add 'hairpin' port forwarding mode
- [Bridge] [PATCH] bridge-utils: Add 'hairpin' port forwarding mode