jckarter/clay — Issue #48: bindgen fails to generate the bindings for unix on linux64
Author: Blei
Created: 2011-12-12 10:10:00+00:00
State: open

Specifically, it generates multiple instances of one struct. Error message:

```
###############################
external (cdecl) recvmmsg(arg0:Int, arg1:Pointer[Struct_mmsghdr], arg2:UInt, arg3:Int, arg4:Pointer[Struct_timespec]) : Int;

alias Struct_mmsghdr = Opaque;
------^

external (cdecl) sendmmsg(arg0:Int, arg1:Pointer[Struct_mmsghdr], arg2:UInt, arg3:Int) : Int;
###############################
/home/philipp/programming/clay/build/compiler/src/../../../lib-clay/unix/generated/generated.linux.64.clay(1503,6): error: name redefined: Struct_mmsghdr
```

Excerpt of the generated file:

```
alias Struct_mmsghdr = Opaque;
external (cdecl) recvmmsg(arg0:Int, arg1:Pointer[Struct_mmsghdr], arg2:UInt, arg3:Int, arg4:Pointer[Struct_timespec]) : Int;
alias Struct_mmsghdr = Opaque;
external (cdecl) sendmmsg(arg0:Int, arg1:Pointer[Struct_mmsghdr], arg2:UInt, arg3:Int) : Int;
```

This gets generated from the file :

```c
#ifdef __USE_GNU
/* For `recvmmsg'. */
struct mmsghdr
{
struct msghdr msg_hdr;	/* Actual message header. */
unsigned int msg_len;	/* Number of received bytes for the entry. */
};
#endif

[...]

/* Receive up to VLEN messages as described by VMESSAGES from socket FD.
Returns the number of bytes read or -1 for errors.

This function is a cancellation point and therefore not marked with
__THROW. */
extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
unsigned int __vlen, int __flags,
__const struct timespec *__tmo);

/* Send a VLEN messages as described by VMESSAGES to socket FD.
Return the number of datagrams successfully written or -1 for errors.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
unsigned int __vlen, int __flags);

```

After removing the duplicate definition, everything works.

I'm not quite sure what is happening here. Apparently bindgen doesn't pick up the mmsghdr struct (because it doesn't define __USE_GNU?).