]> Savannah Git Hosting - gnulib.git/commitdiff
stdalign: Fix compilation error with MSVC in C++ mode.
authorBruno Haible <bruno@clisp.org>
Sun, 1 Jan 2023 09:01:19 +0000 (10:01 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 1 Jan 2023 09:10:04 +0000 (10:10 +0100)
* lib/stdalign.in.h: Treat MSVC in C++ mode like C++11 compliant
compilers.

ChangeLog
lib/stdalign.in.h

index 5f32077c97bc29f55cab794424897db4e5a9a0ea..5363f048eee3a2f72d3d0e31e59213a9255df0f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-09-24  Bruno Haible  <bruno@clisp.org>
+
+       stdalign: Fix compilation error with MSVC in C++ mode.
+       * lib/stdalign.in.h: Treat MSVC in C++ mode like C++11 compliant
+       compilers.
+
 2022-09-20  Bruno Haible  <bruno@clisp.org>
 
        snippet/warn-on-use: Don't cause wrong AC_CHECK_DECL results with clang.
index 3b117df11fe25f9985adfa75c9c2850fcb21da2e..c1e0df1fdcf96b8259f7a7bf173278b95e1a8589 100644 (file)
@@ -61,7 +61,7 @@
          && !defined __clang__) \
      || (defined __clang__ && __clang_major__ < 8))
 # ifdef __cplusplus
-#  if 201103 <= __cplusplus
+#  if (201103 <= __cplusplus || defined _MSC_VER)
 #   define _Alignof(type) alignof (type)
 #  else
    template <class __t> struct __alignof_helper { char __a; __t __b; };
@@ -71,7 +71,7 @@
 #  define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
 # endif
 #endif
-#if ! (defined __cplusplus && 201103 <= __cplusplus)
+#if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
 # define alignof _Alignof
 #endif
 #define __alignof_is_defined 1
    */
 
 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
-# if defined __cplusplus && 201103 <= __cplusplus
+# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
 #  define _Alignas(a) alignas (a)
 # elif (!defined __attribute__ \
         && ((defined __APPLE__ && defined __MACH__ \
 #  define _Alignas(a) __declspec (align (a))
 # endif
 #endif
-#if ((defined _Alignas && ! (defined __cplusplus && 201103 <= __cplusplus)) \
+#if ((defined _Alignas \
+      && ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
      || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
 # define alignas _Alignas
 #endif
-#if defined alignas || (defined __cplusplus && 201103 <= __cplusplus)
+#if (defined alignas \
+     || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
 # define __alignas_is_defined 1
 #endif