[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] broken OpenBSD <net/if.h> [was: [PATCH] Include some extra headers needed for OpenBSD.]



On Tue, Sep 04, 2012 at 11:08:30AM -0600, Eric Blake wrote:
> [adding gnulib]
> 
> On 09/04/2012 10:52 AM, Jasper Lievisse Adriaanse wrote:
> >> I'd still like to know the compiler error you got when <sys/socket.h>
> >> was not present, but just guessing from the source code, I see one call
> >> of socket() (protected behind #if defined(HAVE_NET_IF_H) &&
> >> defined(SIOCBRADDBR), but maybe those are both true for OpenBSD?).  Even
> >> though I'm pushing, I would STILL like to know why.
> > Of course, here it is:
> > 
> > In file included from util/virnetdevbridge.c:35:
> > /usr/include/net/if.h:276: warning: 'struct sockaddr' declared inside
> > parameter list
> 
> Ouch.  The POSIX definition of <net/if.h> doesn't include any interface
> that needs to use struct sockaddr.  Which OpenBSD extension function is
> triggering this warning? According to POSIX, this .c file should compile:
> 
> #define _POSIX_C_SOURCE 200809L
> #include <net/if.h>
> #include <sys/socket.h>
> struct if_nameindex i;
> 
> and it might just compile on OpenBSD (I haven't checked myself); the
> difference is that we have explicitly asked for namespace pollution
> beyond what _POSIX_C_SOURCE guarantees, which may explain why 'struct
> sockaddr' is interfering.  But since <net/if.h> is required to be
> self-contained when in a strict environment, it makes sense for it to
> also be self-contained in an extension environment.  It sounds like
> gnulib should consider providing a replacement <net/if.h> function to
> work around this lameness.
> 
> -- 
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
That snippet of example code does not compile on OpenBSD:

In file included from foo.c:2:
/usr/include/net/if.h:112: error: expected specifier-qualifier-list before 'u_int'
/usr/include/net/if.h:125: error: expected specifier-qualifier-list before 'u_char'
/usr/include/net/if.h:188: error: expected specifier-qualifier-list before 'u_char'
/usr/include/net/if.h:262: error: expected specifier-qualifier-list before 'u_short'
/usr/include/net/if.h:474: error: expected specifier-qualifier-list before 'u_int'
/usr/include/net/if.h:485: error: expected specifier-qualifier-list before 'u_int'
/usr/include/net/if.h:493: error: expected specifier-qualifier-list before 'u_short'
/usr/include/net/if.h:512: error: expected specifier-qualifier-list before 'u_short'
/usr/include/net/if.h:530: error: expected specifier-qualifier-list before 'u_short'
/usr/include/net/if.h:551: error: expected specifier-qualifier-list before 'u_int'
/usr/include/net/if.h:586: error: expected specifier-qualifier-list before 'u_int'
/usr/include/net/if.h:606: error: field 'ifru_addr' has incomplete type
/usr/include/net/if.h:607: error: field 'ifru_dstaddr' has incomplete type
/usr/include/net/if.h:608: error: field 'ifru_broadaddr' has incomplete type
/usr/include/net/if.h:626: error: field 'ifra_addr' has incomplete type
/usr/include/net/if.h:627: error: field 'ifra_dstaddr' has incomplete type
/usr/include/net/if.h:629: error: field 'ifra_mask' has incomplete type
/usr/include/net/if.h:673: error: field 'addr' has incomplete type
/usr/include/net/if.h:674: error: field 'dstaddr' has incomplete type
In file included from /usr/include/net/if.h:691,
                 from foo.c:2:
/usr/include/net/if_arp.h:79: error: field 'arp_pa' has incomplete type
/usr/include/net/if_arp.h:80: error: field 'arp_ha' has incomplete type
*** Error code 1

Could you please reference where POSIX states it should, so this can hopefully
get fixed in OpenBSD.

-- 
Cheers,
Jasper

"Stay Hungry. Stay Foolish"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]