]> 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:37:26 +0000 (09:37 +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 5d4022fb472899b4b151c7b34a4e6b5aa9bf00af..ae9cbae8a4ec1263a3742edf05faff707bc04cb2 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 df2cb183a526456214575263d76b10b86b87673d..7c5ea0946838691a129c3124ab618a5306b5b4eb 100644 (file)
@@ -1,5 +1,5 @@
 /* getopt (basic, portable features) gnulib wrapper header.
-   Copyright (C) 1989-2024 Free Software Foundation, Inc.
+   Copyright (C) 1989-2025 Free Software Foundation, Inc.
    This file is part of gnulib.
    Unlike most of the getopt implementation, it is NOT shared
    with the GNU C Library.
@@ -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 0b50620c4b2e18c6ffbf55b4977f2dae6603b306..03c91e78708b2ccaecbb85356974ea432110c600 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
@@ -34,6 +35,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)