2 * Copyright 2016 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <folly/portability/Config.h>
21 #if defined(FOLLY_HAVE_LIBGFLAGS) && (FOLLY_HAVE_LIBGFLAGS == 0)
22 // glog/logging.h is dependent on this implementation detail
23 // being defined otherwise it undefines all of this -_-....
25 // Also, this is deliberately expanded such that places using
26 // it directly break loudly. (C will break louder than C++, but oh well)
27 #define DECLARE_VARIABLE() \
28 static_assert(false, "You shouldn't be using GFlags internals.");
30 #define FOLLY_DECLARE_FLAG(_type, _shortType, _name) \
31 namespace fL##_shortType { \
32 extern _type FLAGS_##_name; \
34 using fL##_shortType::FLAGS_##_name
36 #define DECLARE_bool(_name) FOLLY_DECLARE_FLAG(bool, B, _name)
37 #define DECLARE_double(_name) FOLLY_DECLARE_FLAG(double, D, _name)
38 #define DECLARE_int32(_name) FOLLY_DECLARE_FLAG(int, I, _name)
39 #define DECLARE_int64(_name) FOLLY_DECLARE_FLAG(long long, I64, _name)
40 #define DECLARE_uint64(_name) FOLLY_DECLARE_FLAG(unsigned long long, U64, _name)
41 #define DECLARE_string(_name) FOLLY_DECLARE_FLAG(std::string, S, _name)
43 #define FOLLY_DEFINE_FLAG(_type, _shortType, _name, _default) \
44 namespace fL##_shortType { \
45 _type FLAGS_##_name = _default; \
47 using fL##_shortType::FLAGS_##_name
49 #define DEFINE_bool(_name, _default, _description) \
50 FOLLY_DEFINE_FLAG(bool, B, _name, _default)
51 #define DEFINE_double(_name, _default, _description) \
52 FOLLY_DEFINE_FLAG(double, D, _name, _default)
53 #define DEFINE_int32(_name, _default, _description) \
54 FOLLY_DEFINE_FLAG(int, I, _name, _default)
55 #define DEFINE_int64(_name, _default, _description) \
56 FOLLY_DEFINE_FLAG(long long, I64, _name, _default)
57 #define DEFINE_uint64(_name, _default, _description) \
58 FOLLY_DEFINE_FLAG(unsigned long long, U64, _name, _default)
59 #define DEFINE_string(_name, _default, _description) \
60 FOLLY_DEFINE_FLAG(std::string, S, _name, _default)
62 #include <gflags/gflags.h>