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