> 2024-09-21 Bruno Haible <br...@clisp.org> > > getopt-posix, crypto/md5-buffer: Fix __GNUC_PREREQ re clang.
This change causes a compilation error on Solaris 11 OmniOS in C++ mode: g++ -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/root/include -Wall -DCONTINUE_AFTER_ASSERT -D_REENTRANT -Wno-error -g -O2 -MT test-list-c++.o -MD -MP -MF $depbase.Tpo -c -o test-list-c++.o ../../gltests/test-list-c++.cc &&\ mv -f $depbase.Tpo $depbase.Po In file included from ../gllib/unistd.h:714, from ../gllib/stdlib.h:120, from ../../gltests/../gllib/xalloc.h:29, from ../../gltests/../gllib/gl_xlist.h:28, from ../../gltests/../gllib/gl_list.hh:22, from ../../gltests/test-list-c++.cc:20: ../config.h:7953:25: error: declaration of 'int rpl_getopt(int, char* const*, const char*)' has a different exception specifier 7953 | #define __GETOPT_PREFIX rpl_ | ^~~~ ../config.h:7953:25: note: from previous declaration 'int rpl_getopt(int, char* const*, const char*) noexcept' 7953 | #define __GETOPT_PREFIX rpl_ | ^~~~ gmake[4]: *** [Makefile:27627: test-list-c++.o] Error 1 The cause is that stdio.h has a declaration of getopt(), which was not yet seen when the '#define getopt rpl_getopt' took effect. This patch fixes it. 2024-09-23 Bruno Haible <br...@clisp.org> getopt-posix: Fix compilation error in C++ mode (regression 2024-09-21). * lib/getopt-pfx-core.h: On AIX, HP-UX, Solaris, QNX, include <stdio.h> first. diff --git a/lib/getopt-pfx-core.h b/lib/getopt-pfx-core.h index 78b7816aa4..df2cb183a5 100644 --- a/lib/getopt-pfx-core.h +++ b/lib/getopt-pfx-core.h @@ -31,6 +31,13 @@ functions and variables. Renaming avoids problems with some compilers and linkers. */ #ifdef __GETOPT_PREFIX + +/* Include platform-dependent header files that may declare getopt() and + friends. */ +# if defined _AIX || defined __hpux || defined __sun || defined __QNX__ +# include <stdio.h> +# endif + # ifndef __GETOPT_ID # define __GETOPT_CONCAT(x, y) x ## y # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)