Skip to content

Commit

Permalink
util: Add DECLARE_uint32 to gflags compatibility (#396)
Browse files Browse the repository at this point in the history
Fixes: #395, fix compilation on fedora.
  • Loading branch information
AmnonHanuhov committed Feb 14, 2023
1 parent 2369e50 commit a83f8b8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions util/gflags_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#pragma once
#include <gflags/gflags.h>

#include <functional>

#ifndef GFLAGS_NAMESPACE
// in case it's not defined in old versions, that's probably because it was
// still google by default.
Expand All @@ -16,10 +18,13 @@
// DEFINE_uint32 does not appear in older versions of gflags. This should be
// a sane definition for those versions.
#include <cstdint>
#define DEFINE_uint32(name, val, txt) \
namespace gflags_compat { \
DEFINE_int32(name, val, txt); \
} \
uint32_t &FLAGS_##name = \
*reinterpret_cast<uint32_t *>(&gflags_compat::FLAGS_##name);
#endif
#define DEFINE_uint32(name, val, txt) \
namespace gflags_compat { \
DEFINE_int32(name, val, txt); \
} \
std::reference_wrapper<uint32_t> FLAGS_##name = \
std::ref(*reinterpret_cast<uint32_t *>(&gflags_compat::FLAGS_##name));

#define DECLARE_uint32(name) \
extern std::reference_wrapper<uint32_t> FLAGS_##name;
#endif // !DEFINE_uint32

0 comments on commit a83f8b8

Please sign in to comment.