]> Savannah Git Hosting - gnulib.git/commitdiff
assert-h, verify: Fix compilation error in C++ mode with MSVC 14.
authorBruno Haible <bruno@clisp.org>
Sun, 5 Feb 2023 10:19:28 +0000 (11:19 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 10 Feb 2023 03:08:01 +0000 (04:08 +0100)
* lib/verify.h (static_assert): Define _ALLOW_KEYWORD_MACROS.
* tests/test-assert-h-c++.cc: Strengthen test.
* tests/test-assert-h-c++2.cc: Likewise.

ChangeLog
lib/verify.h
tests/test-assert-h-c++.cc
tests/test-assert-h-c++2.cc

index eea8ce0dc284fca2ac7c93c5c7a567e048809d77..07e8b0870abe1ed202fccb1723d79ab7ff7086fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-02-05  Bruno Haible  <bruno@clisp.org>
+
+       assert-h, verify: Fix compilation error in C++ mode with MSVC 14.
+       * lib/verify.h (static_assert): Define _ALLOW_KEYWORD_MACROS.
+       * tests/test-assert-h-c++.cc: Strengthen test.
+       * tests/test-assert-h-c++2.cc: Likewise.
+
 2023-02-04  Bruno Haible  <bruno@clisp.org>
 
        assert-h, verify: Fix conflict with standard C++ header files on macOS.
index e4a8278e035c7c2961d27bfef35f50086a71a9c1..ec0a41eb9c49a507a5bd21fae9056df679d1f9d6 100644 (file)
@@ -264,6 +264,8 @@ template <int w>
 #   define _GL_SA3 static_assert
 #   define _GL_SA_PICK(x1,x2,x3,x4,...) x4
 #   define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__)
+/* Avoid "fatal error C1189: #error:  The C++ Standard Library forbids macroizing keywords."  */
+#   define _ALLOW_KEYWORD_MACROS 1
 #  else
 #   define static_assert _Static_assert /* C11 requires this #define. */
 #  endif
index 6b76565633960469664e4c139ffe0ab58e425b5e..7da8b377fd8cc25e3197c220241d9acc6a6c1272 100644 (file)
@@ -26,6 +26,9 @@
 #include <iostream>
 
 
+static_assert (2 + 2 == 4, "arithmetic does not work");
+static_assert (2 + 2 == 4);
+
 int
 main ()
 {
index ffd7c8cf9261c23ebd72fc7e275e4c224ddb1674..8808886202954b9068556e3d273df7b7dc80e83c 100644 (file)
@@ -22,3 +22,7 @@
 /* Check against conflicts between <cassert> and other C++ header files.  */
 #include <stddef.h>
 #include <iostream>
+
+
+static_assert (2 + 2 == 4, "arithmetic does not work");
+static_assert (2 + 2 == 4);