gflags_compat.h 1.0 KB

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #pragma once
  6. #include <gflags/gflags.h>
  7. #include <functional>
  8. #ifndef GFLAGS_NAMESPACE
  9. // in case it's not defined in old versions, that's probably because it was
  10. // still google by default.
  11. #define GFLAGS_NAMESPACE google
  12. #endif
  13. #ifndef DEFINE_uint32
  14. // DEFINE_uint32 / DECLARE_uint32 do not appear in older versions of gflags.
  15. // These should be sane definitions for those versions.
  16. #include <cstdint>
  17. #define DEFINE_uint32(name, val, txt) \
  18. namespace gflags_compat { \
  19. DEFINE_int32(name, val, txt); \
  20. } \
  21. uint32_t &FLAGS_##name = \
  22. *reinterpret_cast<uint32_t *>(&gflags_compat::FLAGS_##name);
  23. #define DECLARE_uint32(name) extern uint32_t &FLAGS_##name;
  24. #endif // !DEFINE_uint32