]> Savannah Git Hosting - gnulib.git/commitdiff
assert-h, stdbool: Fix compilation error with MSVC 14 (regr. yesterday).
authorBruno Haible <bruno@clisp.org>
Wed, 30 Oct 2024 14:56:41 +0000 (15:56 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 30 Oct 2024 14:56:41 +0000 (15:56 +0100)
* m4/assert_h.m4 (gl_ASSERT_H): Add parentheses to the preprocessor
expression.
* m4/c-bool.m4 (gl_C_BOOL): Likewise.

ChangeLog
m4/assert_h.m4
m4/c-bool.m4

index 8484e2d2615080e665e5ac5c7eac788d425cf236..83143af50f83092d3c6ac7bbdc8666a23e43768d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-10-30  Bruno Haible  <bruno@clisp.org>
+
+       assert-h, stdbool: Fix compilation error with MSVC 14 (regr. yesterday).
+       * m4/assert_h.m4 (gl_ASSERT_H): Add parentheses to the preprocessor
+       expression.
+       * m4/c-bool.m4 (gl_C_BOOL): Likewise.
+
 2024-10-29  Paul Eggert  <eggert@cs.ucla.edu>
 
        malloc, realloc: sync from Autoconf master
index 9bdb3c4f033d5d63fa62a28538911a6cb7226dbc..8f772f0a639aeaa4fc87b9fdb34f3d39cfb9ab93 100644 (file)
@@ -1,5 +1,5 @@
 # assert_h.m4
-# serial 2
+# serial 3
 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -50,6 +50,10 @@ AC_DEFUN([gl_ASSERT_H],
 
   dnl The "zz" puts this toward config.h's end, to avoid potential
   dnl collisions with other definitions.
+  dnl Hardcode the known configuration results for GCC and clang, so that
+  dnl a configuration made with the C compiler works also with the C++ compiler
+  dnl and vice versa.
+  dnl The seemingly redundant parentheses are necessary for MSVC 14.
   dnl #undef assert so that programs are not tempted to use it without
   dnl specifically including assert.h.
   dnl #undef __ASSERT_H__ so that on IRIX, when programs later include
@@ -60,12 +64,12 @@ AC_DEFUN([gl_ASSERT_H],
 [#if (!(defined __clang__ \
        ? (defined __cplusplus \
           ? __cplusplus >= 201703L \
-          : __STDC_VERSION__ >= 202000L && __clang_major__ >= 16) \
-       defined __GNUC__ \
-       ? (defined __cplusplus \
-          ? __cplusplus >= 201103L && __GNUG__ >= 6 \
-          : __STDC_VERSION__ >= 202000L && __GNUC__ >= 13) : \
-       defined HAVE_C_STATIC_ASSERT) \
+          : __STDC_VERSION__ >= 202000L && __clang_major__ >= 16) \
+       : (defined __GNUC__ \
+          ? (defined __cplusplus \
+             ? __cplusplus >= 201103L && __GNUG__ >= 6 \
+             : __STDC_VERSION__ >= 202000L && __GNUC__ >= 13) \
+          : defined HAVE_C_STATIC_ASSERT)) \
      && !defined assert \
      && (!defined __cplusplus \
          || (__cpp_static_assert < 201411 \
index 8ea186d1cf879b509204a19291005e68524cd1d2..fa792b12a1400b1211b17d41ea1c70d7f8515b24 100644 (file)
@@ -1,5 +1,5 @@
 # c-bool.m4
-# serial 2
+# serial 3
 dnl Copyright 2022-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -30,15 +30,23 @@ AC_DEFUN([gl_C_BOOL],
   dnl The "zz" puts this toward config.h's end, to avoid potential
   dnl collisions with other definitions.
   dnl If 'bool', 'true' and 'false' do not work, arrange for them to work.
-  dnl In C, this means including <stdbool.h> if it is not already included.
+  dnl Hardcode the known configuration results for GCC and clang, so that
+  dnl a configuration made with the C compiler works also with the C++ compiler
+  dnl and vice versa.
+  dnl The seemingly redundant parentheses are necessary for MSVC 14.
+  dnl "Arrange for them to work", in C, means including <stdbool.h> if it is
+  dnl not already included.
   dnl However, if the preprocessor mistakenly treats 'true' as 0,
   dnl define it to a bool expression equal to 1; this is needed in
   dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older.
   AH_VERBATIM([zzbool],
-[#if !(defined __cplusplus ? 1 : \
-      defined __clang__ ? __STDC_VERSION__ >= 202000L && __clang_major__ >= 15 : \
-      defined __GNUC__ ? __STDC_VERSION__ >= 202000L && __GNUC__ >= 13 : \
-      defined HAVE_C_BOOL)
+[#if !(defined __cplusplus \
+      ? 1 \
+      : (defined __clang__ \
+         ? __STDC_VERSION__ >= 202000L && __clang_major__ >= 15 \
+         : (defined __GNUC__ \
+            ? __STDC_VERSION__ >= 202000L && __GNUC__ >= 13 \
+            : defined HAVE_C_BOOL)))
 # if !defined __cplusplus && !defined __bool_true_false_are_defined
 #  if HAVE_STDBOOL_H
 #   include <stdbool.h>