Fixed Visual Studio 2022: protobuf\src\google\protobuf\arena.cc(457,51): error C2127: 'thread_cache_': illegal initialization of 'constinit' entity with a non-constant expression #11672 (#11674)

Closes #11674

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/11674 from chronoxor:main ed65deafa7
PiperOrigin-RevId: 505009868
pull/11691/head
Ivan Shynkarenka 2 years ago committed by Copybara-Service
parent 48ff4f6219
commit c2e99a1ee4
  1. 2
      src/google/protobuf/arena.cc
  2. 2
      src/google/protobuf/thread_safe_arena.h

@ -453,7 +453,7 @@ ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
return thread_cache;
}
#else
ABSL_CONST_INIT PROTOBUF_THREAD_LOCAL
PROTOBUF_CONSTINIT PROTOBUF_THREAD_LOCAL
ThreadSafeArena::ThreadCache ThreadSafeArena::thread_cache_;
#endif

@ -260,7 +260,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
// wrap them in static functions.
static ThreadCache& thread_cache();
#else
ABSL_CONST_INIT static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_;
PROTOBUF_CONSTINIT static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_;
static ThreadCache& thread_cache() { return thread_cache_; }
#endif

Loading…
Cancel
Save