+2024-05-30 Bruno Haible <bruno@clisp.org>
+
+ assert-h, verify: Fix compilation error with g++ (4.8.5) -std=gnu++11.
+ Reported by Harmen <harmen@stoppels.ch> at
+ <https://savannah.gnu.org/bugs/index.php?65811>.
+ * lib/verify.h (static_assert): In C++ mode with g++ < 6 and
+ -std=gnu++11, define in a way that supports also the 1-argument
+ invocations and the invocations inside C++ struct and class.
+
2024-05-31 Bruno Haible <bruno@clisp.org>
windows-once: Free allocated resources when done.
/* Compile-time assert-like macros.
- Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
&& (!defined __cplusplus \
|| (__cpp_static_assert < 201411 \
&& __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910)))
-# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
+# if (defined __cplusplus && defined __GNUG__ && __GNUG__ < 6 \
+ && __cplusplus == 201103L && !defined __clang__)
+/* g++ >= 4.7, < 6 with option -std=c++11 or -std=gnu++11 supports the
+ two-arguments static_assert but not the one-argument static_assert, and
+ it does not support _Static_assert.
+ We have to play preprocessor tricks to distinguish the two cases. */
+# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
+# define _GL_SA2 static_assert
+# define _GL_SA3 static_assert
+# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
+# define static_assert(...) _GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1) (__VA_ARGS__)
+# elif defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
/* MSVC 14 in C++ mode supports the two-arguments static_assert but not
the one-argument static_assert, and it does not support _Static_assert.
We have to play preprocessor tricks to distinguish the two cases.
- Since the MSVC preprocessor is not ISO C compliant (see above),.
+ Since the MSVC preprocessor is not ISO C compliant (see above),
the solution is specific to MSVC. */
# define _GL_EXPAND(x) x
# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")