Libevent introduced the typeof
C language extension in the NetBSD-specific code, which was pulled into our depends in #21991.
However, GCC states:
the various
-std
options disable certain keywords.
Due to our use of https://github.com/bitcoin/bitcoin/blob/b042c4f0538c6f9cdf8efbcef552796851e38a85/depends/hosts/netbsd.mk#L1
the typeof
keyword is disabled, resulting in a compilation error:
0$ gmake -C depends libevent CC=/usr/pkg/gcc14/bin/gcc CXX=/usr/pkg/gcc14/bin/g++
1<snip>
2[ 37%] Building C object CMakeFiles/event_core_static.dir/kqueue.c.o
3/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c: In function 'kq_setup_kevent':
4/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:56:27: error: implicit declaration of function 'typeof' [-Wimplicit-function-declaration]
5 56 | #define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
6 | ^~~~~~
7/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:190:30: note: in expansion of macro 'INT_TO_UDATA'
8 190 | out->udata = INT_TO_UDATA(ADD_UDATA);
9 | ^~~~~~~~~~~~
10/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:56:64: error: expected expression before 'intptr_t'
11 56 | #define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
12 | ^~~~~~~~
13/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:190:30: note: in expansion of macro 'INT_TO_UDATA'
14 190 | out->udata = INT_TO_UDATA(ADD_UDATA);
15 | ^~~~~~~~~~~~
16/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:56:27: error: called object is not a function or function pointer
17 56 | #define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
18 | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:190:30: note: in expansion of macro 'INT_TO_UDATA'
20 190 | out->udata = INT_TO_UDATA(ADD_UDATA);
21 | ^~~~~~~~~~~~
22gmake[3]: *** [CMakeFiles/event_core_static.dir/build.make:328: CMakeFiles/event_core_static.dir/kqueue.c.o] Error 1
23<snip>
This PR resolves this issue by following GCC’s recommendation:
write
__typeof__
instead oftypeof
.