1 // Copyright (c) 1999, Google Inc.
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // Revamped and reorganized by Craig Silverstein
34 // This is the file that should be included by any file which declares
37 #ifndef GFLAGS_DECLARE_H_
38 #define GFLAGS_DECLARE_H_
41 // ---------------------------------------------------------------------------
42 // Namespace of gflags library symbols.
43 #define GFLAGS_NAMESPACE @GFLAGS_NAMESPACE@
45 // ---------------------------------------------------------------------------
46 // Windows DLL import/export.
48 // Whether gflags library is a DLL.
50 // Set to 1 by default when the shared gflags library was built on Windows.
51 // Must be overwritten when this header file is used with the optionally also
52 // built static library instead; set by CMake's INTERFACE_COMPILE_DEFINITIONS.
53 #ifndef GFLAGS_IS_A_DLL
54 # define GFLAGS_IS_A_DLL @GFLAGS_IS_A_DLL@
57 // We always want to import the symbols of the gflags library.
58 #ifndef GFLAGS_DLL_DECL
59 # if GFLAGS_IS_A_DLL && defined(_MSC_VER)
60 # define GFLAGS_DLL_DECL __declspec(dllimport)
62 # define GFLAGS_DLL_DECL
66 // We always want to import variables declared in user code.
67 #ifndef GFLAGS_DLL_DECLARE_FLAG
68 # if GFLAGS_IS_A_DLL && defined(_MSC_VER)
69 # define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
71 # define GFLAGS_DLL_DECLARE_FLAG
75 // ---------------------------------------------------------------------------
79 # include <stdint.h> // the normal place uint32_t is defined
80 #elif @HAVE_SYS_TYPES_H@
81 # include <sys/types.h> // the normal place u_int32_t is defined
82 #elif @HAVE_INTTYPES_H@
83 # include <inttypes.h> // a third place for uint32_t or u_int32_t
86 namespace GFLAGS_NAMESPACE {
88 #if @GFLAGS_INTTYPES_FORMAT_C99@ // C99
89 typedef int32_t int32;
90 typedef uint32_t uint32;
91 typedef int64_t int64;
92 typedef uint64_t uint64;
93 #elif @GFLAGS_INTTYPES_FORMAT_BSD@ // BSD
94 typedef int32_t int32;
95 typedef u_int32_t uint32;
96 typedef int64_t int64;
97 typedef u_int64_t uint64;
98 #elif @GFLAGS_INTTYPES_FORMAT_VC7@ // Windows
99 typedef __int32 int32;
100 typedef unsigned __int32 uint32;
101 typedef __int64 int64;
102 typedef unsigned __int64 uint64;
104 # error Do not know how to define a 32-bit integer quantity on your system
107 } // namespace GFLAGS_NAMESPACE
112 // The meaning of "string" might be different between now and when the
113 // macros below get invoked (e.g., if someone is experimenting with
114 // other string implementations that get defined after this file is
115 // included). Save the current meaning now and use it in the macros.
116 typedef std::string clstring;
121 #define DECLARE_VARIABLE(type, shorttype, name) \
122 /* We always want to import declared variables, dll or no */ \
123 namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \
124 using fL##shorttype::FLAGS_##name
126 #define DECLARE_bool(name) \
127 DECLARE_VARIABLE(bool, B, name)
129 #define DECLARE_int32(name) \
130 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name)
132 #define DECLARE_uint32(name) \
133 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint32, U, name)
135 #define DECLARE_int64(name) \
136 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name)
138 #define DECLARE_uint64(name) \
139 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint64, U64, name)
141 #define DECLARE_double(name) \
142 DECLARE_VARIABLE(double, D, name)
144 #define DECLARE_string(name) \
145 /* We always want to import declared variables, dll or no */ \
147 using ::fLS::clstring; \
148 extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
150 using fLS::FLAGS_##name
153 #endif // GFLAGS_DECLARE_H_