• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 GFLAGS_DECLARE_H_
38#define GFLAGS_DECLARE_H_
39
40
41// ---------------------------------------------------------------------------
42// Namespace of gflags library symbols.
43#define GFLAGS_NAMESPACE @GFLAGS_NAMESPACE@
44
45// ---------------------------------------------------------------------------
46// Windows DLL import/export.
47
48// Whether gflags library is a DLL.
49//
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@
55#endif
56
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)
61#  elif defined(__GNUC__) && __GNUC__ >= 4
62#    define GFLAGS_DLL_DECL __attribute__((visibility("default")))
63#  else
64#    define GFLAGS_DLL_DECL
65#  endif
66#endif
67
68// We always want to import variables declared in user code.
69#ifndef GFLAGS_DLL_DECLARE_FLAG
70#  if GFLAGS_IS_A_DLL && defined(_MSC_VER)
71#    define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
72#  elif defined(__GNUC__) && __GNUC__ >= 4
73#    define GFLAGS_DLL_DECLARE_FLAG __attribute__((visibility("default")))
74#  else
75#    define GFLAGS_DLL_DECLARE_FLAG
76#  endif
77#endif
78
79// ---------------------------------------------------------------------------
80// Flag types
81#include <string>
82#if @HAVE_STDINT_H@
83#  include <stdint.h>                   // the normal place uint32_t is defined
84#elif @HAVE_SYS_TYPES_H@
85#  include <sys/types.h>                // the normal place u_int32_t is defined
86#elif @HAVE_INTTYPES_H@
87#  include <inttypes.h>                 // a third place for uint32_t or u_int32_t
88#endif
89
90namespace GFLAGS_NAMESPACE {
91
92#if @GFLAGS_INTTYPES_FORMAT_C99@ // C99
93typedef int32_t          int32;
94typedef uint32_t         uint32;
95typedef int64_t          int64;
96typedef uint64_t         uint64;
97#elif @GFLAGS_INTTYPES_FORMAT_BSD@ // BSD
98typedef int32_t          int32;
99typedef u_int32_t        uint32;
100typedef int64_t          int64;
101typedef u_int64_t        uint64;
102#elif @GFLAGS_INTTYPES_FORMAT_VC7@ // Windows
103typedef __int32          int32;
104typedef unsigned __int32 uint32;
105typedef __int64          int64;
106typedef unsigned __int64 uint64;
107#else
108#  error Do not know how to define a 32-bit integer quantity on your system
109#endif
110
111} // namespace GFLAGS_NAMESPACE
112
113
114namespace fLS {
115
116// The meaning of "string" might be different between now and when the
117// macros below get invoked (e.g., if someone is experimenting with
118// other string implementations that get defined after this file is
119// included).  Save the current meaning now and use it in the macros.
120typedef std::string clstring;
121
122} // namespace fLS
123
124
125#define DECLARE_VARIABLE(type, shorttype, name) \
126  /* We always want to import declared variables, dll or no */ \
127  namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \
128  using fL##shorttype::FLAGS_##name
129
130#define DECLARE_bool(name) \
131  DECLARE_VARIABLE(bool, B, name)
132
133#define DECLARE_int32(name) \
134  DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name)
135
136#define DECLARE_uint32(name) \
137  DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint32, U, name)
138
139#define DECLARE_int64(name) \
140  DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name)
141
142#define DECLARE_uint64(name) \
143  DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint64, U64, name)
144
145#define DECLARE_double(name) \
146  DECLARE_VARIABLE(double, D, name)
147
148#define DECLARE_string(name) \
149  /* We always want to import declared variables, dll or no */ \
150  namespace fLS { \
151  extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
152  } \
153  using fLS::FLAGS_##name
154
155
156#endif  // GFLAGS_DECLARE_H_
157