bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: Fix compilation errors in C++ mode on macOS 12.5
Date: Thu, 09 Feb 2023 19:05:35 +0100	[thread overview]
Message-ID: <2711412.nXWkaXXXjU@nimes> (raw)

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'
#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_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
compiler.


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.  */
 #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
 # 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





                 reply	other threads:[~2023-02-09 18:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2711412.nXWkaXXXjU@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).