xlab / c-for-go

Automatic C-Go Bindings Generator for Go Programming Language
https://c.for-go.com
MIT License
1.5k stars 119 forks source link

wlroots: Undefined: __typeof__ and others #107

Open joscha-alisch opened 3 years ago

joscha-alisch commented 3 years ago

I'm trying to generate bindings for wlroots, but encountered lots of issues parsing headers.

Trying to break it down into manageable chunks and I'm currently trying to just parse wayland-server-core.h which is the main dependency of wlroots.

c-for-go fails with the following message:

/usr/include/wayland-server-core.h:458:2: undefined: __typeof__
/usr/include/wayland-server-core.h:458:2: undefined: __typeof__
/usr/include/wayland-server-core.h:458:2: undefined: __builtin_offsetof
/usr/include/wayland-server-core.h:458:2: called object is not a function or function pointer (have '<undefined>')
/usr/include/wayland-server-core.h:458:46: undefined: link
/usr/include/wayland-server-core.h:458:2: called object is not a function or function pointer (have '<undefined>')
/usr/include/wayland-server-core.h:458:2: called object is not a function or function pointer (have '<undefined>')
/usr/include/wayland-server-core.h:458:2: called object is not a function or function pointer (have '<undefined>')
/usr/include/wayland-server-core.h:458:2: assignment from incompatible type ('struct wl_listener*' = '<undefined>')
/usr/include/wayland-server-core.h:458:2: undefined: __typeof__
too many errors

When I use "--ccdefs", I get the following

[ERR] /usr/include/bits/byteswap.h:37:10: called object is not a function or function pointer (have '<undefined>') (and 6 more errors)

Not sure if with that flag it fails at an earlier or later point in parsing. Anyways, in an attempt to just push through, I also included a stub file with the functions missing in byteswap.h:

static inline unsigned short __builtin_bswap16(unsigned short a)
{
    return (a<<8)|(a>>8);
}

static inline unsigned short __builtin_bswap32(unsigned short a)
{
    return (a<<16)|(a>>16);
}

static inline unsigned short __builtin_bswap64(unsigned short a)
{
    return (a<<32)|(a>>32);
}

after which I get the following:

[ERR] /usr/include/bits/mathcalls.h:53:1: unexpected identifier acosf32, expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]

So something seems very messed up here. Anything obvious I'm doing wrong? Is wlroots possibly too complex for c-for-go?