From b4d78189b348144723264025ad549800a340e2ae Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Mon, 3 Apr 2023 10:41:00 -0700 Subject: [PATCH] Fix gflags_compat.h (#11346) Summary: Was getting compilation failure with old verison of gflags, examples in https://github.com/facebook/rocksdb/issues/11344. Perhaps this is new since enabling C++17. Getting rid of std::reference_wrapper from https://github.com/facebook/rocksdb/issues/10729 seems to fix it. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11346 Test Plan: manual, CI Reviewed By: guowentian Differential Revision: D44632776 Pulled By: pdillinger fbshipit-source-id: 5c1f3f79a055698574538b6342c912a627b6d061 --- util/gflags_compat.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/util/gflags_compat.h b/util/gflags_compat.h index b6f88a5bc..8f4a30b0d 100644 --- a/util/gflags_compat.h +++ b/util/gflags_compat.h @@ -15,16 +15,15 @@ #endif #ifndef DEFINE_uint32 -// DEFINE_uint32 does not appear in older versions of gflags. This should be -// a sane definition for those versions. +// DEFINE_uint32 / DECLARE_uint32 do not appear in older versions of gflags. +// These should be sane definitions for those versions. #include -#define DEFINE_uint32(name, val, txt) \ - namespace gflags_compat { \ - DEFINE_int32(name, val, txt); \ - } \ - std::reference_wrapper FLAGS_##name = \ - std::ref(*reinterpret_cast(&gflags_compat::FLAGS_##name)); +#define DEFINE_uint32(name, val, txt) \ + namespace gflags_compat { \ + DEFINE_int32(name, val, txt); \ + } \ + uint32_t &FLAGS_##name = \ + *reinterpret_cast(&gflags_compat::FLAGS_##name); -#define DECLARE_uint32(name) \ - extern std::reference_wrapper FLAGS_##name; +#define DECLARE_uint32(name) extern uint32_t &FLAGS_##name; #endif // !DEFINE_uint32