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 // We always want to import the symbols of the gflags library
49 #ifndef GFLAGS_DLL_DECL
50 # if @GFLAGS_IS_A_DLL@ && defined(_MSC_VER)
51 # define GFLAGS_DLL_DECL __declspec(dllimport)
53 # define GFLAGS_DLL_DECL
57 // We always want to import variables declared in user code
58 #ifndef GFLAGS_DLL_DECLARE_FLAG
59 # if @GFLAGS_IS_A_DLL@ && defined(_MSC_VER)
60 # define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
62 # define GFLAGS_DLL_DECLARE_FLAG
66 // ---------------------------------------------------------------------------
70 # include <stdint.h> // the normal place uint32_t is defined
71 #elif @HAVE_SYS_TYPES_H@
72 # include <sys/types.h> // the normal place u_int32_t is defined
73 #elif @HAVE_INTTYPES_H@
74 # include <inttypes.h> // a third place for uint32_t or u_int32_t
77 namespace GFLAGS_NAMESPACE {
79 #if @GFLAGS_INTTYPES_FORMAT_C99@ // C99
80 typedef int32_t int32;
81 typedef uint32_t uint32;
82 typedef int64_t int64;
83 typedef uint64_t uint64;
84 #elif @GFLAGS_INTTYPES_FORMAT_BSD@ // BSD
85 typedef int32_t int32;
86 typedef u_int32_t uint32;
87 typedef int64_t int64;
88 typedef u_int64_t uint64;
89 #elif @GFLAGS_INTTYPES_FORMAT_VC7@ // Windows
90 typedef __int32 int32;
91 typedef unsigned __int32 uint32;
92 typedef __int64 int64;
93 typedef unsigned __int64 uint64;
95 # error Do not know how to define a 32-bit integer quantity on your system
98 } // namespace GFLAGS_NAMESPACE
103 // The meaning of "string" might be different between now and when the
104 // macros below get invoked (e.g., if someone is experimenting with
105 // other string implementations that get defined after this file is
106 // included). Save the current meaning now and use it in the macros.
107 typedef std::string clstring;
112 #define DECLARE_VARIABLE(type, shorttype, name) \
113 /* We always want to import declared variables, dll or no */ \
114 namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \
115 using fL##shorttype::FLAGS_##name
117 #define DECLARE_bool(name) \
118 DECLARE_VARIABLE(bool, B, name)
120 #define DECLARE_int32(name) \
121 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name)
123 #define DECLARE_uint32(name) \
124 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint32, U, name)
126 #define DECLARE_int64(name) \
127 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name)
129 #define DECLARE_uint64(name) \
130 DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint64, U64, name)
132 #define DECLARE_double(name) \
133 DECLARE_VARIABLE(double, D, name)
135 #define DECLARE_string(name) \
136 /* We always want to import declared variables, dll or no */ \
138 using ::fLS::clstring; \
139 extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
141 using fLS::FLAGS_##name
144 #endif // GFLAGS_DECLARE_H_