From 91df9959f027239bc16100654c5d453a8a4becde Mon Sep 17 00:00:00 2001 From: "G. Branden Robinson" Date: Sun, 16 Apr 2023 00:30:29 -0500 Subject: [PATCH] [build]: Improve portability to unfree compilers. * bootstrap.conf (gnulib_modules): Add "attribute". * src/libs/libgroff/getopt.c: * src/libs/libgroff/new.cpp: Include gnulib's "attribute.h" header file. * src/libs/libgroff/getopt.c (_getopt_initialize): * src/libs/libgroff/new.cpp (operator delete): Replace GNU C unused attribute syntax with gnulib's "MAYBE_UNUSED". Thanks to Bruno Haible for the report and suggested remedy. ANNOUNCE: Drop item about builds failing with MSVC due to GNU C-style attribute usage. This might no longer happen, but there could be other reasons we don't successfully build with it. --- ANNOUNCE | 4 ---- ChangeLog | 14 ++++++++++++++ bootstrap.conf | 1 + src/libs/libgroff/getopt.c | 5 +++-- src/libs/libgroff/new.cpp | 5 +++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index ae9ab65d1..624dda8c4 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -179,10 +179,6 @@ o Solaris 10 has known problems with automated tests; see the "PROBLEMS" o There is a problem building on "newlib"-using systems when X11 support is enabled; see the "PROBLEMS" file in the distribution archive. -o The build is known to not work with the MSVC compiler. There are no - plans to address this before C23 standardized attributes become - available. - News ==== diff --git a/ChangeLog b/ChangeLog index 8c9ff8091..7441dad2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2023-04-16 G. Branden Robinson + + [build]: Improve portability to non-GNU, non-LLVM compilers. + + * bootstrap.conf (gnulib_modules): Add "attribute". + * src/libs/libgroff/getopt.c: + * src/libs/libgroff/new.cpp: Include gnulib's "attribute.h" + header file. + * src/libs/libgroff/getopt.c (_getopt_initialize): + * src/libs/libgroff/new.cpp (operator delete): Replace GNU C + unused attribute syntax with gnulib's "MAYBE_UNUSED". + + Thanks to Bruno Haible for the report and suggested remedy. + 2023-03-16 G. Branden Robinson * src/libs/libxutil/XFontName.c (utoa): Rename function from diff --git a/bootstrap.conf b/bootstrap.conf index 7a2099fb8..aa96ac6df 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -36,6 +36,7 @@ checkout_only_file=README.git # havelib provides config.rpath # can be get through gettext though gnulib_modules=" + attribute git-version-gen havelib wcwidth diff --git a/src/libs/libgroff/getopt.c b/src/libs/libgroff/getopt.c index 6efa5299b..2bf2eee8e 100644 --- a/src/libs/libgroff/getopt.c +++ b/src/libs/libgroff/getopt.c @@ -28,6 +28,8 @@ # include #endif +#include // gnulib: MAYBE_UNUSED + #include /* This needs to come after some library #include @@ -248,8 +250,7 @@ exchange (char **argv, struct _getopt_data *d) /* Initialize the internal data when the first call is made. */ static const char * -_getopt_initialize (__attribute__((__unused__)) int argc, - __attribute__((__unused__)) char **argv, +_getopt_initialize (MAYBE_UNUSED int argc, MAYBE_UNUSED char **argv, const char *optstring, int posixly_correct, struct _getopt_data *d) { diff --git a/src/libs/libgroff/new.cpp b/src/libs/libgroff/new.cpp index 2af976cf4..73b24efd9 100644 --- a/src/libs/libgroff/new.cpp +++ b/src/libs/libgroff/new.cpp @@ -16,6 +16,8 @@ for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include // gnulib: MAYBE_UNUSED + #include "lib.h" #include @@ -54,8 +56,7 @@ void operator delete(void *p) throw() free(p); } -void operator delete(void *p, - __attribute__((__unused__)) long unsigned int size) +void operator delete(void *p, MAYBE_UNUSED long unsigned int size) { // It's ugly to duplicate the code from delete(void *) above, but if // we don't, g++ 6.3 can't figure out we're calling through it to