From fde75446490e18d2539817ca418ab8adf73b02d3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 27 Dec 2022 11:21:45 +0100 Subject: Fix compilation errors in C++ mode on Solaris 11 OpenIndiana. * m4/gnulib-common.m4 (gl_COMMON_BODY): In _GL_ATTRIBUTE_DEALLOC_FREE, with GNU C++, cast the 'free' function. * lib/string.in.h (_GL_ATTRIBUTE_DEALLOC_FREE): With GNU C++, cast the 'free' function. * lib/wchar.in.h (_GL_ATTRIBUTE_DEALLOC_FREE): Likewise. --- ChangeLog | 9 +++++++++ lib/string.in.h | 9 ++++++++- lib/wchar.in.h | 9 ++++++++- m4/gnulib-common.m4 | 11 +++++++++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index aeacc1dae6..c5de4b0809 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2022-12-27 Bruno Haible + + Fix compilation errors in C++ mode on Solaris 11 OpenIndiana. + * m4/gnulib-common.m4 (gl_COMMON_BODY): In _GL_ATTRIBUTE_DEALLOC_FREE, + with GNU C++, cast the 'free' function. + * lib/string.in.h (_GL_ATTRIBUTE_DEALLOC_FREE): With GNU C++, cast the + 'free' function. + * lib/wchar.in.h (_GL_ATTRIBUTE_DEALLOC_FREE): Likewise. + 2022-12-27 Bruno Haible stdnoreturn: Mark as deprecated, not obsolete. (Regression 2022-12-24.) diff --git a/lib/string.in.h b/lib/string.in.h index 21356914e2..64a0ab19f7 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -82,7 +82,14 @@ can be freed via 'free'; it can be used only after declaring 'free'. */ /* Applies to: functions. Cannot be used on inline functions. */ #ifndef _GL_ATTRIBUTE_DEALLOC_FREE -# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) +# if defined __cplusplus && defined __GNUC__ && !defined __clang__ +/* Work around GCC bug */ +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) +# else +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC (free, 1) +# endif #endif /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly diff --git a/lib/wchar.in.h b/lib/wchar.in.h index 3558adfb9d..70b8d7d259 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -99,7 +99,14 @@ can be freed via 'free'; it can be used only after declaring 'free'. */ /* Applies to: functions. Cannot be used on inline functions. */ #ifndef _GL_ATTRIBUTE_DEALLOC_FREE -# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) +# if defined __cplusplus && defined __GNUC__ && !defined __clang__ +/* Work around GCC bug */ +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) +# else +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC (free, 1) +# endif #endif /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 728a006ce8..40c19cab69 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 74 +# gnulib-common.m4 serial 75 dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -187,7 +187,14 @@ AC_DEFUN([gl_COMMON_BODY], [ to use this earlier definition, since may not have been included yet. */ #ifndef _GL_ATTRIBUTE_DEALLOC_FREE -# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) +# if defined __cplusplus && defined __GNUC__ && !defined __clang__ +/* Work around GCC bug */ +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) +# else +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC (free, 1) +# endif #endif /* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated. -- cgit v1.2.1