Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Oct 29, 2024 · 4 comments

Comments

@barracuda156
Copy link
Contributor

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 **

  • NNG version: 1.9.0
  • Operating system and version: macOS 10.6
  • Compiler and language used: gcc 14.2.0
  • Shared or static library: static

Additional context
Add any other context about the problem here.

@gdamore
Copy link
Contributor

gdamore commented Oct 29, 2024

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
Copy link
Contributor

gdamore commented Oct 29, 2024

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

@barracuda156
Copy link
Contributor Author

barracuda156 commented Oct 29, 2024

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 #1900 (comment)

@barracuda156
Copy link
Contributor Author

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

gdamore added a commit that referenced this issue Nov 8, 2024
This bug was already fixed in the main branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants