From: Bruno Haible Date: Sun, 1 Jan 2023 09:01:19 +0000 (+0100) Subject: stdalign: Fix compilation error with MSVC in C++ mode. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=1239f241349daec7b59ec5ea7b828e42313ca024;p=gnulib.git stdalign: Fix compilation error with MSVC in C++ mode. * lib/stdalign.in.h: Treat MSVC in C++ mode like C++11 compliant compilers. --- diff --git a/ChangeLog b/ChangeLog index 5f32077c97..5363f048ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2022-09-24 Bruno Haible + + 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 snippet/warn-on-use: Don't cause wrong AC_CHECK_DECL results with clang. diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h index 3b117df11f..c1e0df1fdc 100644 --- a/lib/stdalign.in.h +++ b/lib/stdalign.in.h @@ -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 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 @@ -102,7 +102,7 @@ */ #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__ \ @@ -116,11 +116,13 @@ # 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