]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
fts: Fix redefinition of __THROW.
authorCollin Funk <collin.funk1@gmail.com>
Sat, 10 May 2025 23:07:57 +0000 (16:07 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 10 May 2025 23:07:57 +0000 (16:07 -0700)
* lib/fts_.h: Include <sys/cdefs.h> if the system has it.
(__THROW, __BEGIN_DECLS, __END_DECLS): Define properly if not previously
defined.
* m4/fts.m4 (gl_FUNC_FTS_CORE): Check for sys/cdefs.h.

ChangeLog
lib/fts_.h
m4/fts.m4

index 2d7696a717789c2617c66c3e008c51bc39daa199..6c248f533af3310eb118a6cb29e3d2f164752197 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-05-10  Collin Funk  <collin.funk1@gmail.com>
+
+       fts: Fix redefinition of __THROW.
+       * lib/fts_.h: Include <sys/cdefs.h> if the system has it.
+       (__THROW, __BEGIN_DECLS, __END_DECLS): Define properly if not previously
+       defined.
+       * m4/fts.m4 (gl_FUNC_FTS_CORE): Check for sys/cdefs.h.
+
 2025-05-10  Bruno Haible  <bruno@clisp.org>
 
        string-desc, xstring-desc: Avoid GCC attributes in function definitions.
index 9fb4c62df9d4171949327f7e198f00e128d4d803..052858da7b924fccede38bb54eec601d80e8719f 100644 (file)
 #   define __FLEXIBLE_ARRAY_MEMBER
 #  endif
 # else
+#  if HAVE_SYS_CDEFS_H
+#   include <sys/cdefs.h>
+#  endif
 #  define __FLEXIBLE_ARRAY_MEMBER FLEXIBLE_ARRAY_MEMBER
-#  undef __THROW
-#  define __THROW
-#  undef __BEGIN_DECLS
-#  undef __END_DECLS
-#  ifdef __cplusplus
-#   define __BEGIN_DECLS extern "C" {
-#   define __END_DECLS }
-#  else
-#   define __BEGIN_DECLS
-#   define __END_DECLS
+#  ifndef __THROW
+#   if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
+#    if __cplusplus >= 201103L
+#     define __THROW      noexcept (true)
+#    else
+#     define __THROW      throw ()
+#    endif
+#   else
+#    define __THROW
+#   endif
+#  endif
+#  ifndef __BEGIN_DECLS
+#   ifdef __cplusplus
+#    define __BEGIN_DECLS extern "C" {
+#   else
+#    define __BEGIN_DECLS /* nothing */
+#   endif
+#  endif
+#  ifndef __END_DECLS
+#   ifdef __cplusplus
+#    define __END_DECLS }
+#   else
+#    define __END_DECLS /* nothing */
+#   endif
 #  endif
 # endif
 
index 1c230bb93fdceadb8ce6091e8889b4e22e466707..1d3a32f52e1472d6c6640ddbffd221c1467c967f 100644 (file)
--- a/m4/fts.m4
+++ b/m4/fts.m4
@@ -1,5 +1,5 @@
 # fts.m4
-# serial 24
+# serial 25
 dnl Copyright (C) 2005-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,6 +15,7 @@ AC_DEFUN([gl_FUNC_FTS_CORE],
 [
   dnl Prerequisites of lib/fts.c.
   gl_FUNC_OPENAT
+  AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
 
   AC_CHECK_FUNCS_ONCE([fstatfs])
   AC_CHECK_HEADERS_ONCE([sys/param.h sys/vfs.h])dnl