nanomsg / nng

nanomsg-next-generation -- light-weight brokerless messaging
https://nng.nanomsg.org
MIT License
3.84k stars 491 forks source link

1.9.0 fails to build: `error: 'u_int32_t' undeclared (first use in this function); did you mean 'uint32_t'?` #1900

Open barracuda156 opened 1 week ago

barracuda156 commented 1 week ago
FAILED: CMakeFiles/nng.dir/src/platform/posix/posix_udp.c.o 
/opt/local/bin/ccache /opt/local/bin/gcc-mp-14 -DNNG_ENABLE_COMPAT -DNNG_ENABLE_IPV6 -DNNG_ENABLE_STATS -DNNG_HAVE_ARC4RANDOM=1 -DNNG_HAVE_BACKTRACE=1 -DNNG_HAVE_BUS0 -DNNG_HAVE_CLOCK_GETTIME -DNNG_HAVE_CLOCK_GETTIME_LIBC=1 -DNNG_HAVE_FLOCK=1 -DNNG_HAVE_GETPEEREID=1 -DNNG_HAVE_INET6=1 -DNNG_HAVE_KQUEUE=1 -DNNG_HAVE_LANGINFO=1 -DNNG_HAVE_LIBATOMIC=1 -DNNG_HAVE_LOCALPEERCRED=1 -DNNG_HAVE_LOCALTIME_R=1 -DNNG_HAVE_LOCKF=1 -DNNG_HAVE_MSG_CONTROL=1 -DNNG_HAVE_PAIR0 -DNNG_HAVE_PAIR1 -DNNG_HAVE_PTHREAD_ATFORK_PTHREAD=1 -DNNG_HAVE_PTHREAD_SETNAME_NP=1 -DNNG_HAVE_PUB0 -DNNG_HAVE_PULL0 -DNNG_HAVE_PUSH0 -DNNG_HAVE_REP0 -DNNG_HAVE_REQ0 -DNNG_HAVE_RESPONDENT0 -DNNG_HAVE_SEMAPHORE_PTHREAD=1 -DNNG_HAVE_SOCKETPAIR=1 -DNNG_HAVE_STDATOMIC=1 -DNNG_HAVE_STRCASECMP=1 -DNNG_HAVE_STRLCPY=1 -DNNG_HAVE_STRNCASECMP=1 -DNNG_HAVE_STRNLEN=1 -DNNG_HAVE_SUB0 -DNNG_HAVE_SURVEYOR0 -DNNG_HAVE_TIMESPEC_GET=1 -DNNG_HAVE_UNIX_SOCKETS=1 -DNNG_HIDDEN_VISIBILITY -DNNG_MAX_EXPIRE_THREADS=8 -DNNG_MAX_POLLER_THREADS=8 -DNNG_MAX_TASKQ_THREADS=16 -DNNG_PLATFORM_DARWIN -DNNG_PLATFORM_POSIX -DNNG_PRIVATE -DNNG_RESOLV_CONCURRENCY=4 -DNNG_STATIC_LIB -DNNG_SUPP_HTTP -DNNG_SUPP_TLS -DNNG_SUPP_TLS_PSK -DNNG_TLS_ENGINE_FINI=nng_tls_engine_fini_mbed -DNNG_TLS_ENGINE_INIT=nng_tls_engine_init_mbed -DNNG_TLS_ENGINE_MBEDTLS -DNNG_TRANSPORT_FDC -DNNG_TRANSPORT_INPROC -DNNG_TRANSPORT_IPC -DNNG_TRANSPORT_TCP -DNNG_TRANSPORT_TLS -DNNG_TRANSPORT_WS -DNNG_TRANSPORT_WSS -D_GNU_SOURCE -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_THREAD_SAFE -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_nng/nng/work/nng-1.9.0/src -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_nng/nng/work/nng-1.9.0/include -isystem /opt/local/include -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -Wall -Wextra -fno-omit-frame-pointer   -std=gnu99 -arch ppc -mmacosx-version-min=10.6 -MD -MT CMakeFiles/nng.dir/src/platform/posix/posix_udp.c.o -MF CMakeFiles/nng.dir/src/platform/posix/posix_udp.c.o.d -o CMakeFiles/nng.dir/src/platform/posix/posix_udp.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_nng/nng/work/nng-1.9.0/src/platform/posix/posix_udp.c
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_nng/nng/work/nng-1.9.0/src/platform/posix/posix_udp.c:21:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_nng/nng/work/nng-1.9.0/src/platform/posix/posix_udp.c: In function 'ip4_multicast_member':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_nng/nng/work/nng-1.9.0/src/platform/posix/posix_udp.c:364:45: error: 'u_int32_t' undeclared (first use in this function); did you mean 'uint32_t'?
  364 |                 mreq.imr_interface.s_addr = INADDR_ANY;
      |                                             ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_nng/nng/work/nng-1.9.0/src/platform/posix/posix_udp.c:364:45: note: each undeclared identifier is reported only once for each function it appears in
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_nng/nng/work/nng-1.9.0/src/platform/posix/posix_udp.c:364:45: error: expected ';' before numeric constant
  364 |                 mreq.imr_interface.s_addr = INADDR_ANY;
      |                                             ^~~~~~~~~~

Environment Details

Additional context Add any other context about the problem here.

gdamore commented 1 week ago

Wow, looks like a bad definition in macOS headers:

in netinet/in.h:

#define INADDR_ANY              (u_int32_t)0x00000000

Probably some other header needs to be included that defines u_int32_t... that's a strange type and not part of the normal POSIX definitions.

gdamore commented 1 week ago

Probably <sys/types.h> should be included.

barracuda156 commented 1 week ago

I have found an earlier error like this, it is something related to macOS headers on legacy systems. This fixes it:

--- src/platform/posix/posix_udp.c  2024-09-08 06:43:34.000000000 +0800
+++ src/platform/posix/posix_udp.c  2024-10-29 09:07:16.000000000 +0800
@@ -23,6 +23,10 @@
 #include <sys/socket.h>
 #include <unistd.h>

+#ifdef __APPLE__
+typedef uint32_t u_int32_t;
+#endif
+
 // UDP support.

 // If we can suppress SIGPIPE on send, please do so.

UPD. A better fix is https://github.com/nanomsg/nng/issues/1900#issuecomment-2442961681

barracuda156 commented 1 week ago

@gdamore Yes, you are absolutely right, including sys/types.h before netinet/in.h fixes it.