From 4441ccc75a6c6e90ee81449e35fc8bc32cf7a9ea Mon Sep 17 00:00:00 2001 From: jgcodes2020 Date: Fri, 8 Jul 2022 08:58:46 -0400 Subject: [PATCH 1/2] "Fix" MSVC 17 constinit issues --- src/google/protobuf/port_def.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index c694a8b7c619..8debb7fbd4f6 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -667,7 +667,7 @@ #ifdef PROTOBUF_CONSTINIT #error PROTOBUF_CONSTINIT was previously defined #endif -#if defined(__cpp_constinit) +#if defined(__cpp_constinit) && !defined(_MSC_VER) #define PROTOBUF_CONSTINIT constinit #define PROTOBUF_CONSTEXPR constexpr // Some older Clang versions incorrectly raise an error about @@ -682,6 +682,11 @@ #elif PROTOBUF_GNUC_MIN(12, 2) #define PROTOBUF_CONSTINIT __constinit #define PROTOBUF_CONSTEXPR constexpr +// MSVC 17 currently seems to raise an error about constant-initialized pointers. +#elif defined(_MSC_VER) && _MSC_VER >= 1930 +#define PROTOBUF_CONSTINIT +#define PROTOBUF_CONSTEXPR constexpr +#endif #else #define PROTOBUF_CONSTINIT #define PROTOBUF_CONSTEXPR From cd8cd75c3300738d7848b9d3f13849c7a6be4e56 Mon Sep 17 00:00:00 2001 From: jgcodes2020 Date: Fri, 8 Jul 2022 22:14:29 -0400 Subject: [PATCH 2/2] Fix erroneous endif --- src/google/protobuf/port_def.inc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 8debb7fbd4f6..29f454dd316c 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -189,13 +189,10 @@ // Used to remove the manipulation of cleared elements in RepeatedPtrField. // Owner: mkruskal@ #define PROTOBUF_FUTURE_REMOVE_CLEARED_API 1 -<<<<<<< HEAD -======= // Used to escape C++20 keywords. // Owner: mkruskal@ #define PROTOBUF_FUTURE_CPP20_KEYWORDS 1 ->>>>>>> 87d285c785cd1a4334e3e21e5d468a9bc3e85f62 #else #define PROTOBUF_FUTURE_FINAL #endif @@ -686,7 +683,6 @@ #elif defined(_MSC_VER) && _MSC_VER >= 1930 #define PROTOBUF_CONSTINIT #define PROTOBUF_CONSTEXPR constexpr -#endif #else #define PROTOBUF_CONSTINIT #define PROTOBUF_CONSTEXPR