1 // Copyright (c) 1999, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
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
13 // distribution.
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.
17 //
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.
29 
30 // ---
31 //
32 // Revamped and reorganized by Craig Silverstein
33 //
34 // This is the file that should be included by any file which declares
35 // command line flag.
36 
37 #ifndef BASE_COMMANDLINEFLAGS_DECLARE_H_
38 #define BASE_COMMANDLINEFLAGS_DECLARE_H_
39 
40 #include <string>
41 #if 0
42 #include <stdint.h>         // the normal place uint16_t is defined
43 #endif
44 #if 1
45 #include <sys/types.h>      // the normal place u_int16_t is defined
46 #endif
47 #if 0
48 #include <inttypes.h>       // a third place for uint16_t or u_int16_t
49 #endif
50 
51 namespace google {
52 #if 0      // the C99 format
53 typedef int32_t int32;
54 typedef uint32_t uint32;
55 typedef int64_t int64;
56 typedef uint64_t uint64;
57 #elif 0   // the BSD format
58 typedef int32_t int32;
59 typedef u_int32_t uint32;
60 typedef int64_t int64;
61 typedef u_int64_t uint64;
62 #elif 1     // the windows (vc7) format
63 typedef __int32 int32;
64 typedef unsigned __int32 uint32;
65 typedef __int64 int64;
66 typedef unsigned __int64 uint64;
67 #else
68 #error Do not know how to define a 32-bit integer quantity on your system
69 #endif
70 }
71 
72 
73 #if defined(_MSC_VER) && !defined(GFLAGS_DLL_DECLARE_FLAG)
74 # define GFLAGS_DLL_DECLARE_FLAG  __declspec(dllimport)
75 #endif
76 
77 namespace fLS {
78 
79 // The meaning of "string" might be different between now and when the
80 // macros below get invoked (e.g., if someone is experimenting with
81 // other string implementations that get defined after this file is
82 // included).  Save the current meaning now and use it in the macros.
83 typedef std::string clstring;
84 
85 }
86 
87 #define DECLARE_VARIABLE(type, shorttype, name) \
88   /* We always want to import declared variables, dll or no */ \
89   namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \
90   using fL##shorttype::FLAGS_##name
91 
92 #define DECLARE_bool(name) \
93   DECLARE_VARIABLE(bool, B, name)
94 
95 #define DECLARE_int32(name) \
96   DECLARE_VARIABLE(::google::int32, I, name)
97 
98 #define DECLARE_int64(name) \
99   DECLARE_VARIABLE(::google::int64, I64, name)
100 
101 #define DECLARE_uint64(name) \
102   DECLARE_VARIABLE(::google::uint64, U64, name)
103 
104 #define DECLARE_double(name) \
105   DECLARE_VARIABLE(double, D, name)
106 
107 #define DECLARE_string(name) \
108   namespace fLS {                       \
109   using ::fLS::clstring;                \
110   extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
111   }                                     \
112   using fLS::FLAGS_##name
113 
114 #endif  // BASE_COMMANDLINEFLAGS_DECLARE_H_
115