bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Fix compilation errors in C++ mode on macOS 12.5
@ 2023-02-09 18:05 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2023-02-09 18:05 UTC (permalink / raw)
  To: bug-gnulib

Building a Gnulib testdir on macOS 12.5, I see many compilation errors like
this one:

../../gltests/test-dirent-c++.cc:28:1: error: expected expression
SIGNATURE_CHECK (GNULIB_NAMESPACE::opendir, DIR *, (const char *));
../../gltests/signature.h:39:3: note: expanded from macro 'SIGNATURE_CHECK'
  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
../../gltests/signature.h:44:3: note: expanded from macro 'SIGNATURE_CHECK1'
  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
../../gltests/signature.h:46:3: note: expanded from macro 'SIGNATURE_CHECK2'
  _GL_UNUSED static ret (*signature_check ## id) args = fn
../config.h:7536:20: note: expanded from macro '_GL_UNUSED'
../config.h:7523:40: note: expanded from macro '_GL_ATTRIBUTE_MAYBE_UNUSED'
#   define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]

The macroexpanded line is:

[[__maybe_unused__]] static DIR * (*signature_check28) (const char *) = gnulib::Opendir;

The fix is to define _GL_ATTRIBUTE_MAYBE_UNUSED differently, with this

2023-02-09  Bruno Haible  <bruno@clisp.org>

	Fix compilation errors in C++ mode on macOS 12.5.
	* m4/gnulib-common.m4 (gl_COMMON_BODY): Don't define
	_GL_ATTRIBUTE_MAYBE_UNUSED to [[__maybe_unused__]] if the compiler is
	an Apple variant of clang.

diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index c0181abdc5..1e6748ed8c 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 80
+# gnulib-common.m4 serial 81
 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -356,7 +356,7 @@ AC_DEFUN([gl_COMMON_BODY], [
    [[__maybe_unused__]] nevertheless produces a warning.  */
 # if defined __clang__ && defined __cplusplus
-#  if __clang_major__ >= 10
+#  if !defined __apple_build_version__ && __clang_major__ >= 10
 #   define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
 #  endif
 # elif defined __has_c_attribute

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-09 18:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 18:05 Fix compilation errors in C++ mode on macOS 12.5 Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).