diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 8bd06d340f7c3..cae9ebe01ec2c 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -434,19 +434,26 @@ # define PROTOBUF_EXPORT __declspec(dllexport) # define PROTOBUF_EXPORT_TEMPLATE_DECLARE # define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport) +# define PROTOBUF_CONSTINIT_WITH_PTR PROTOBUF_CONSTINIT # else # define PROTOBUF_EXPORT __declspec(dllimport) # define PROTOBUF_EXPORT_TEMPLATE_DECLARE # define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport) +// Pointers to dllimport extern variables on Windows require a static +// initialization and cannot be constant-initialized. This macro disables +// constinit in files where we cannot support it. +# define PROTOBUF_CONSTINIT_WITH_PTR # endif // defined(LIBPROTOBUF_EXPORTS) #elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS) # define PROTOBUF_EXPORT __attribute__((visibility("default"))) # define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default"))) # define PROTOBUF_EXPORT_TEMPLATE_DEFINE +# define PROTOBUF_CONSTINIT_WITH_PTR PROTOBUF_CONSTINIT #else # define PROTOBUF_EXPORT # define PROTOBUF_EXPORT_TEMPLATE_DECLARE # define PROTOBUF_EXPORT_TEMPLATE_DEFINE +# define PROTOBUF_CONSTINIT_WITH_PTR PROTOBUF_CONSTINIT #endif #ifdef PROTOC_EXPORT diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index 58136a4b47350..056c9b790ba4d 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -80,6 +80,7 @@ #undef PROTOBUF_THREAD_LOCAL #undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT #undef PROTOBUF_CONSTINIT +#undef PROTOBUF_CONSTINIT_WITH_PTR #undef PROTOBUF_CONSTEXPR #undef PROTOBUF_ATTRIBUTE_WEAK #undef PROTOBUF_HAVE_ATTRIBUTE_WEAK -- 2.37.0.rc0.104.g0611611a94-goog