On Fri, 2011-08-05 at 17:45 -0400, Michel Machado wrote:
Hi there,
When an application includes header <linux/netlink.h> obtained with
'make headers_install' or from /usr/include/, it produces the following
error:
/usr/include/linux/netlink.h:31:2: error: expected
specifier-qualifier-list before ‘sa_family_t’
Yeah, I know.
The error doesn't come up in the kernel because
include/linux/netlink.h has the following line:
#include <linux/socket.h> /* for sa_family_t */
However, <linux/socket.h> from /usr/include/ doesn't have sa_family_t
because it's protected by an $ifdef __KERNEL__ in
include/linux/socket.h.
Which is correct, as it would otherwise conflict with <sys/socket.h>.
Previous history:
http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/622621
http://thread.gmane.org/gmane.linux.network/143380
A workaround for an application is to include <sys/socket.h> before
<linux/netlink.h>. However, shouldn't include/linux/netlink.h be fixed?
The simplest solution that I came up was replacing sa_family_t in
include/linux/netlink.h to 'unsigned short' as header
include/linux/socket.h does for struct __kernel_sockaddr_storage
available to applications.
Maybe we should do something like this in <linux/socket.h>:
typedef unsigned short __kernel_sa_family_t;
#ifdef __KERNEL__
typedef __kernel_sa_family_t sa_family_t;
#endif
and then use __kernel_sa_family_t in <linux/netlink.h>.
Ben.