On 01/14/2016 04:06 AM, André Hartmann wrote:
Hello List,

I have written a program which uses SocketCAN for CAN communication.
The development takes place under Ubuntu Linux and compilation is fine
there (also cross-compilation for an embedded ARM Linux).

But when I compile my program under Scientific Linux 6.7, I get the
following errors:

"
In file included from socket_can/receivethread.h:6,
                  from socket_can/receivethread.c:4:
/usr/include/linux/can.h:81: error: expected specifier-qualifier-list
before 'sa_family_t'
socket_can/receivethread.c: In function 'receivethread_init':
socket_can/receivethread.c:52: error: 'struct sockaddr_can' has no
member named 'can_family'
socket_can/receivethread.c:53: error: 'struct sockaddr_can' has no
member named 'can_ifindex'
"

Searching for the definition of sa_family_t gave a lot of usages,
but no definition:

$ cd /usr/include/linux
$ grep -r sa_family_t
llc.h:    sa_family_t     sllc_family;    /* AF_LLC */
llc.h:    sa_family_t    sllc_arphrd;    /* ARPHRD_ETHER */
llc.h:    unsigned char   __pad[__LLC_SOCK_SIZE__ - sizeof(sa_family_t)
* 2 -
rose.h:    sa_family_t    srose_family;
rose.h:    sa_family_t    srose_family;
x25.h:    sa_family_t       sx25_family;        /* Must be AF_X25 */
if_pppox.h:       sa_family_t     sa_family;            /* address
family, AF_PPPOX */
if_pppox.h:    sa_family_t     sa_family;      /* address family,
AF_PPPOX */
in.h:  sa_family_t        sin_family;    /* Address family        */
ax25.h:    sa_family_t    sax25_family;
ipx.h:    sa_family_t    sipx_family;
netlink.h:#include <linux/socket.h> /* for sa_family_t */
netlink.h:    sa_family_t    nl_family;    /* AF_NETLINK    */
can.h:    sa_family_t can_family;
phonet.h:    sa_family_t spn_family;
phonet.h:    __u8 spn_zero[sizeof(struct sockaddr) - sizeof(sa_family_t)
- 3];
un.h:    sa_family_t sun_family;    /* AF_UNIX */
irda.h:    sa_family_t sir_family;   /* AF_IRDA */
atalk.h:    sa_family_t      sat_family;

If I add the typedef to socket.h, everything is fine until the next
kernel update:

typedef unsigned short sa_family_t;

The system is:

$ uname -a
Linux sl67-x64 2.6.32-573.12.1.el6.x86_64 #1 SMP Tue Dec 15 08:24:23 CST
2015 x86_64 x86_64 x86_64 GNU/Linux

Any opinion on this?

Best regards,
André

It looks like sa_family_t has been morphing over time. In SL5, it is indeed defined in linux/socket.h. In SL6 I find it defined in bits/sockaddr.h. In SL7 it continues to be in bits/sockaddr.h, but there is also __kernel_sa_family_t defined in linux/socket.h.

Try adding bits/sockaddr.h to your includes.

-Mark

Reply via email to