]> Savannah Git Hosting - gnulib.git/commitdiff
getopt-posix: Fix compilation error in C++ mode (regression 2024-09-21).
authorBruno Haible <bruno@clisp.org>
Thu, 16 Jan 2025 22:10:10 +0000 (23:10 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 18 Jan 2025 08:17:29 +0000 (09:17 +0100)
Reported by G. Branden Robinson <g.branden.robinson@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-01/msg00135.html>.

* lib/getopt-pfx-core.h: On several platforms, include <unistd.h> first.
* modules/getopt-posix (Files): Add m4/musl.m4.
(configure.ac): Invoke gl_MUSL_LIBC.

ChangeLog
lib/getopt-pfx-core.h
modules/getopt-posix

index 56f26dba47f4cc08d4125e7f780fa7f8ee3720b4..8f2367e2e4b5d6a97d51cc9582f2db5af41d03d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-01-16  Bruno Haible  <bruno@clisp.org>
+
+       getopt-posix: Fix compilation error in C++ mode (regression 2024-09-21).
+       Reported by G. Branden Robinson <g.branden.robinson@gmail.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2025-01/msg00135.html>.
+       * lib/getopt-pfx-core.h: On several platforms, include <unistd.h> first.
+       * modules/getopt-posix (Files): Add m4/musl.m4.
+       (configure.ac): Invoke gl_MUSL_LIBC.
+
 2025-01-16  Bruno Haible  <bruno@clisp.org>
 
        wchar_h: Fix for glibc 2.5.
index 391c7af8e71562023c977c9970eb14fdb66ed75b..7c5ea0946838691a129c3124ab618a5306b5b4eb 100644 (file)
@@ -37,6 +37,9 @@
 # if defined _AIX || defined __hpux || defined __sun || defined __QNX__
 #  include <stdio.h>
 # endif
+# if defined MUSL_LIBC || (defined __FreeBSD__ || defined __DragonFly__) || defined __NetBSD__ || defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined _AIX || defined __sun || defined __minix || defined __HAIKU__
+#  include <unistd.h>
+# endif
 
 # ifndef __GETOPT_ID
 #  define __GETOPT_CONCAT(x, y) x ## y
index 28ab405471d5d090430dcb017cfc80b2c11dc317..f27f5282e43088bd538dc8cf1dd208ecf4164279 100644 (file)
@@ -13,6 +13,7 @@ lib/getopt-pfx-ext.h
 lib/getopt_int.h
 m4/getopt.m4
 m4/sys_cdefs_h.m4
+m4/musl.m4
 
 Depends-on:
 unistd-h
@@ -35,6 +36,7 @@ AM_COND_IF([GL_COND_OBJ_GETOPT], [
   gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1])
 ])
 gl_UNISTD_MODULE_INDICATOR([getopt-posix])
+gl_MUSL_LIBC
 
 Makefile.am:
 BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H)