]> Savannah Git Hosting - gnulib.git/commitdiff
stdalign: Fix compilation error with MSVC in C++ mode.
authorBruno Haible <bruno@clisp.org>
Sat, 24 Sep 2022 22:38:15 +0000 (00:38 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 24 Sep 2022 22:38:15 +0000 (00:38 +0200)
* lib/stdalign.in.h: Treat MSVC in C++ mode like C++11 compliant
compilers.
* tests/test-stdalign-c++.cc: Include some other header files.

ChangeLog
lib/stdalign.in.h
tests/test-stdalign-c++.cc

index b0223bba7ec03d888290ab32f86830dfae141c02..f3468e241fa12c902c5f3c9a75653c63d31a5f5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 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.
+       * tests/test-stdalign-c++.cc: Include some other header files.
+
        stdalign: Avoid namespace pollution.
        * lib/stdalign.in.h (_GL_STDALIGN_NEEDS_STDDEF): New macro.
        Include <stddef.h> only when needed.
index 9ba40e2c45f9f79fd40a1ed8fc97e1471636259f..58fd245c6274d5df38afaaa4f58c3fe001e07889 100644 (file)
@@ -58,7 +58,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; };
@@ -70,7 +70,7 @@
 #  define _GL_STDALIGN_NEEDS_STDDEF 1
 # 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
 
index 8d5258e5f9f272692b5fc8312e4c6e101d0024b6..598b3c1da4de705c3d61802f4eca1b27bb42d0d7 100644 (file)
 
 #include <stdalign.h>
 
+/* Check against conflicts between <stdalign.h> and the C++ header files.  */
+#include <stddef.h>
+#include <iostream>
+
 
 int
 main ()