Commit ac2abfc8 authored by Craig Silverstein's avatar Craig Silverstein

* Split up flag declares into its own file (jyrki)

	* Add --version support (csilvers)
	* Fix doc typo (sudit)
	* Update the README instructions for gflags with static libs (csilvers)


git-svn-id: https://gflags.googlecode.com/svn/trunk@48 6586e3c6-dcc4-952a-343f-ff74eb82781d
parent b4bf72b0
......@@ -21,7 +21,8 @@ AM_LDFLAGS = -no-undefined $(LIBSTDCXX_LA_LINKER_FLAG)
gflagsincludedir = $(includedir)/gflags
## The .h files you want to install (that is, .h files that people
## who install this package can include in their own applications.)
gflagsinclude_HEADERS = src/gflags/gflags.h src/gflags/gflags_completions.h
gflagsinclude_HEADERS = src/gflags/gflags.h src/gflags/gflags_declare.h \
src/gflags/gflags_completions.h
# This is for backwards compatibility only.
googleincludedir = $(includedir)/google
......@@ -206,6 +207,7 @@ libtool: $(LIBTOOL_DEPS)
EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
libtool $(SCRIPTS) \
src/windows/config.h src/windows/port.h src/windows/port.cc \
src/windows/gflags/gflags.h src/windows/gflags/gflags_completions.h \
src/windows/gflags/gflags.h src/windows/gflags/gflags_declare.h \
src/windows/gflags/gflags_completions.h \
$(WINDOWS_PROJECTS) \
src/solaris/libstdc++.la
......@@ -50,9 +50,10 @@ DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \
$(srcdir)/Makefile.in $(top_srcdir)/configure \
$(top_srcdir)/src/config.h.in \
$(top_srcdir)/src/gflags/gflags.h.in \
$(top_srcdir)/src/gflags/gflags_completions.h.in AUTHORS \
COPYING ChangeLog INSTALL NEWS compile config.guess config.sub \
depcomp install-sh ltmain.sh missing mkinstalldirs
$(top_srcdir)/src/gflags/gflags_completions.h.in \
$(top_srcdir)/src/gflags/gflags_declare.h.in AUTHORS COPYING \
ChangeLog INSTALL NEWS compile config.guess config.sub depcomp \
install-sh ltmain.sh missing mkinstalldirs
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_have_attribute.m4 \
......@@ -68,7 +69,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES = src/gflags/gflags.h \
CONFIG_CLEAN_FILES = src/gflags/gflags.h src/gflags/gflags_declare.h \
src/gflags/gflags_completions.h
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
......@@ -316,7 +317,9 @@ AM_CXXFLAGS = $(am__append_1)
# Cygwin and MinGW. LIBSTDCXX_LA_LINKER_FLAG is used to fix a Solaris bug.
AM_LDFLAGS = -no-undefined $(LIBSTDCXX_LA_LINKER_FLAG)
gflagsincludedir = $(includedir)/gflags
gflagsinclude_HEADERS = src/gflags/gflags.h src/gflags/gflags_completions.h
gflagsinclude_HEADERS = src/gflags/gflags.h src/gflags/gflags_declare.h \
src/gflags/gflags_completions.h
# This is for backwards compatibility only.
googleincludedir = $(includedir)/google
......@@ -404,7 +407,8 @@ pkgconfig_DATA = lib${PACKAGE}.pc lib${PACKAGE}_nothreads.pc
EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
libtool $(SCRIPTS) \
src/windows/config.h src/windows/port.h src/windows/port.cc \
src/windows/gflags/gflags.h src/windows/gflags/gflags_completions.h \
src/windows/gflags/gflags.h src/windows/gflags/gflags_declare.h \
src/windows/gflags/gflags_completions.h \
$(WINDOWS_PROJECTS) \
src/solaris/libstdc++.la
......@@ -464,6 +468,8 @@ distclean-hdr:
-rm -f src/config.h src/stamp-h1
src/gflags/gflags.h: $(top_builddir)/config.status $(top_srcdir)/src/gflags/gflags.h.in
cd $(top_builddir) && $(SHELL) ./config.status $@
src/gflags/gflags_declare.h: $(top_builddir)/config.status $(top_srcdir)/src/gflags/gflags_declare.h.in
cd $(top_builddir) && $(SHELL) ./config.status $@
src/gflags/gflags_completions.h: $(top_builddir)/config.status $(top_srcdir)/src/gflags/gflags_completions.h.in
cd $(top_builddir) && $(SHELL) ./config.status $@
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
......
......@@ -15,6 +15,12 @@ have to figure out that part for yourself. If you choose to just
re-use the existing .sln, make sure you set the IncludeDir's
appropriately! Look at the properties for libgflags.dll.
You can also link gflags code in statically. For this to work, you'll
need to add "/D GFLAGS_DLL_DECL=" to the compile line of every
gflags .cc file.
You can also create a static library of gflags. To do this, add
/D GFLAGS_DLL_DECL= /D GFLAGS_DLL_DECLARE_FLAG= /D GFLAGS_DLL_DEFINE_FLAG=
to the compile line of every gflags .cc file.
If you create a static library that *uses* flags (that is, DEFINEs or
DECLAREs flags), you will need to add the following to every .cc file
that defines or declares a flag (it's safe to add them to every .cc
file in your project):
/D GFLAGS_DLL_DECLARE_FLAG= /D GFLAGS_DLL_DEFINE_FLAG=
......@@ -15371,7 +15371,7 @@ $as_echo "#define GFLAGS_DLL_DECL /**/" >>confdefs.h
# Write generated configuration file, and also .h files
ac_config_files="$ac_config_files Makefile src/gflags/gflags.h src/gflags/gflags_completions.h"
ac_config_files="$ac_config_files Makefile src/gflags/gflags.h src/gflags/gflags_declare.h src/gflags/gflags_completions.h"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
......@@ -16442,6 +16442,7 @@ do
"libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/gflags/gflags.h") CONFIG_FILES="$CONFIG_FILES src/gflags/gflags.h" ;;
"src/gflags/gflags_declare.h") CONFIG_FILES="$CONFIG_FILES src/gflags/gflags_declare.h" ;;
"src/gflags/gflags_completions.h") CONFIG_FILES="$CONFIG_FILES src/gflags/gflags_completions.h" ;;
*) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
......
......@@ -114,5 +114,7 @@ AC_DEFINE(GFLAGS_DLL_DECL,,
#includes "config.h" before anything else.])
# Write generated configuration file, and also .h files
AC_CONFIG_FILES([Makefile src/gflags/gflags.h src/gflags/gflags_completions.h])
AC_CONFIG_FILES([Makefile
src/gflags/gflags.h src/gflags/gflags_declare.h
src/gflags/gflags_completions.h])
AC_OUTPUT
......@@ -122,7 +122,7 @@ types supported:</p>
flag in our example is a list of strings, but is defined of type
"string", not "list_of_string" or similar. This is by design. We'd
rather use only simple types for the flags, and allow for complex,
arbitrary parsing routines to parse them, then to try to put the logic
arbitrary parsing routines to parse them, than to try to put the logic
inside the flags library proper.</p>
<p>All DEFINE macros take the same three arguments: the name of the
......
......@@ -81,44 +81,10 @@
#include <string>
#include <vector>
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
// Note: these commands below may look like "#if 1" or "#if 0", but
// that's because they were constructed that way at ./configure time.
// Look at gflags.h.in to see how they're calculated (based on your config).
#if @ac_cv_have_stdint_h@
#include <stdint.h> // the normal place uint16_t is defined
#endif
#if @ac_cv_have_systypes_h@
#include <sys/types.h> // the normal place u_int16_t is defined
#endif
#if @ac_cv_have_inttypes_h@
#include <inttypes.h> // a third place for uint16_t or u_int16_t
#endif
#include <gflags/gflags_declare.h> // IWYU pragma: export
@ac_google_start_namespace@
#if @ac_cv_have_uint16_t@ // the C99 format
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#elif @ac_cv_have_u_int16_t@ // the BSD format
typedef int32_t int32;
typedef u_int32_t uint32;
typedef int64_t int64;
typedef u_int64_t uint64;
#elif @ac_cv_have___int16@ // the windows (vc7) format
typedef __int32 int32;
typedef unsigned __int32 uint32;
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
#error Do not know how to define a 32-bit integer quantity on your system
#endif
// --------------------------------------------------------------------
// To actually define a flag in a file, use DEFINE_bool,
// DEFINE_string, etc. at the bottom of this file. You may also find
......@@ -190,9 +156,9 @@ struct CommandLineFlagInfo {
// TODO(wojtekm) Fix locking when validators are running, to make it safe to
// call validators during ParseAllFlags.
// Also make sure then to uncomment the corresponding unit test in
// commandlineflags_unittest.sh
// gflags_unittest.sh
extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
// These two are actually defined in commandlineflags_reporting.cc.
// These two are actually defined in gflags_reporting.cc.
extern void ShowUsageWithFlags(const char *argv0); // what --help does
extern void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
......@@ -374,10 +340,10 @@ extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
// non-flag argument. (If remove_flags is true, will always return 1.)
extern uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
bool remove_flags);
// This is actually defined in commandlineflags_reporting.cc.
// This is actually defined in gflags_reporting.cc.
// This function is misnamed (it also handles --version, etc.), but
// it's too late to change that now. :-(
extern void HandleCommandLineHelpFlags(); // in commandlineflags_reporting.cc
extern void HandleCommandLineHelpFlags(); // in gflags_reporting.cc
// Allow command line reparsing. Disables the error normally
// generated when an unknown flag is found, since it may be found in a
......@@ -490,12 +456,6 @@ extern const char kStrippedFlagHelp[];
} \
using fL##shorttype::FLAGS_##name
#define DECLARE_VARIABLE(type, shorttype, name) \
namespace fL##shorttype { \
extern type FLAGS_##name; \
} \
using fL##shorttype::FLAGS_##name
// For DEFINE_bool, we want to do the extra check that the passed-in
// value is actually a bool, and not a string or something that can be
// coerced to a bool. These declarations (no definition needed!) will
......@@ -512,7 +472,9 @@ template<typename From> double IsBoolFlag(const From& from);
bool IsBoolFlag(bool from);
} // namespace fLB
#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name)
// Here are the actual DEFINE_*-macros. The respective DECLARE_*-macros
// are in a separate include, gflags_declare.h, for reducing
// the physical transitive size for DECLARE use.
#define DEFINE_bool(name, val, txt) \
namespace fLB { \
typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
......@@ -520,16 +482,12 @@ bool IsBoolFlag(bool from);
} \
DEFINE_VARIABLE(bool, B, name, val, txt)
#define DECLARE_int32(name) DECLARE_VARIABLE(@ac_google_namespace@::int32, I, name)
#define DEFINE_int32(name,val,txt) DEFINE_VARIABLE(@ac_google_namespace@::int32, I, name, val, txt)
#define DECLARE_int64(name) DECLARE_VARIABLE(@ac_google_namespace@::int64, I64, name)
#define DEFINE_int64(name,val,txt) DEFINE_VARIABLE(@ac_google_namespace@::int64, I64, name, val, txt)
#define DECLARE_uint64(name) DECLARE_VARIABLE(@ac_google_namespace@::uint64, U64, name)
#define DEFINE_uint64(name,val,txt) DEFINE_VARIABLE(@ac_google_namespace@::uint64, U64, name, val, txt)
#define DECLARE_double(name) DECLARE_VARIABLE(double, D, name)
#define DEFINE_double(name, val, txt) DEFINE_VARIABLE(double, D, name, val, txt)
// Strings are trickier, because they're not a POD, so we can't
......@@ -540,11 +498,6 @@ bool IsBoolFlag(bool from);
// into it later. It's not perfect, but the best we can do.
namespace fLS {
// The meaning of "string" might be different between now and when the
// macros below get invoked (e.g., if someone is experimenting with
// other string implementations that get defined after this file is
// included). Save the current meaning now and use it in the macros.
typedef std::string clstring;
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
const char *value) {
......@@ -558,9 +511,6 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
int value);
} // namespace fLS
#define DECLARE_string(name) namespace fLS { extern ::fLS::clstring& FLAGS_##name; } \
using fLS::FLAGS_##name
// We need to define a var named FLAGS_no##name so people don't define
// --string and --nostring. And we need a temporary place to put val
// so we don't have to evaluate it twice. Two great needs that go
......
// Copyright (c) 2011, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Ray Sidney
// Revamped and reorganized by Craig Silverstein
//
// This is the file that should be included by any file which declares
// command line flag.
#ifndef BASE_COMMANDLINEFLAGS_DECLARE_H_
#define BASE_COMMANDLINEFLAGS_DECLARE_H_
#include <string>
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
// Note: these commands below may look like "#if 1" or "#if 0", but
// that's because they were constructed that way at ./configure time.
// Look at gflags.h.in to see how they're calculated (based on your config).
#if @ac_cv_have_stdint_h@
#include <stdint.h> // the normal place uint16_t is defined
#endif
#if @ac_cv_have_systypes_h@
#include <sys/types.h> // the normal place u_int16_t is defined
#endif
#if @ac_cv_have_inttypes_h@
#include <inttypes.h> // a third place for uint16_t or u_int16_t
#endif
namespace fLS {
// The meaning of "string" might be different between now and when the
// macros below get invoked (e.g., if someone is experimenting with
// other string implementations that get defined after this file is
// included). Save the current meaning now and use it in the macros.
typedef std::string clstring;
}
@ac_google_start_namespace@
#if @ac_cv_have_uint16_t@ // the C99 format
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#elif @ac_cv_have_u_int16_t@ // the BSD format
typedef int32_t int32;
typedef u_int32_t uint32;
typedef int64_t int64;
typedef u_int64_t uint64;
#elif @ac_cv_have___int16@ // the windows (vc7) format
typedef __int32 int32;
typedef unsigned __int32 uint32;
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
#error Do not know how to define a 32-bit integer quantity on your system
#endif
@ac_google_end_namespace@
#define DECLARE_VARIABLE(type, shorttype, name) \
namespace fL##shorttype { extern type FLAGS_##name; } \
using fL##shorttype::FLAGS_##name
#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name)
#define DECLARE_int32(name) DECLARE_VARIABLE(@ac_google_namespace@::int32, I, name)
#define DECLARE_int64(name) DECLARE_VARIABLE(@ac_google_namespace@::int64, I64, name)
#define DECLARE_uint64(name) DECLARE_VARIABLE(@ac_google_namespace@::uint64, U64, name)
#define DECLARE_double(name) DECLARE_VARIABLE(double, D, name)
#define DECLARE_string(name) \
namespace fLS { \
using ::fLS::clstring; \
extern ::fLS::clstring& FLAGS_##name; \
} \
using fLS::FLAGS_##name
#endif // BASE_COMMANDLINEFLAGS_DECLARE_H_
......@@ -81,22 +81,7 @@
#include <string>
#include <vector>
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
// Note: these commands below may look like "#if 1" or "#if 0", but
// that's because they were constructed that way at ./configure time.
// Look at gflags.h.in to see how they're calculated (based on your config).
#if 0
#include <stdint.h> // the normal place uint16_t is defined
#endif
#if 1
#include <sys/types.h> // the normal place u_int16_t is defined
#endif
#if 0
#include <inttypes.h> // a third place for uint16_t or u_int16_t
#endif
#include <gflags/gflags_declare.h> // IWYU pragma: export
// Annoying stuff for windows -- makes sure clients can import these functions
#if defined(_WIN32)
......@@ -123,25 +108,6 @@
namespace google {
#if 0 // the C99 format
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#elif 0 // the BSD format
typedef int32_t int32;
typedef u_int32_t uint32;
typedef int64_t int64;
typedef u_int64_t uint64;
#elif 1 // the windows (vc7) format
typedef __int32 int32;
typedef unsigned __int32 uint32;
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
#error Do not know how to define a 32-bit integer quantity on your system
#endif
// --------------------------------------------------------------------
// To actually define a flag in a file, use DEFINE_bool,
// DEFINE_string, etc. at the bottom of this file. You may also find
......@@ -213,9 +179,9 @@ struct GFLAGS_DLL_DECL CommandLineFlagInfo {
// TODO(wojtekm) Fix locking when validators are running, to make it safe to
// call validators during ParseAllFlags.
// Also make sure then to uncomment the corresponding unit test in
// commandlineflags_unittest.sh
// gflags_unittest.sh
extern GFLAGS_DLL_DECL void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
// These two are actually defined in commandlineflags_reporting.cc.
// These two are actually defined in gflags_reporting.cc.
extern GFLAGS_DLL_DECL void ShowUsageWithFlags(const char *argv0); // what --help does
extern GFLAGS_DLL_DECL void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
......@@ -233,10 +199,11 @@ extern GFLAGS_DLL_DECL const char* GetArgv0(); // only argv0
extern GFLAGS_DLL_DECL uint32 GetArgvSum(); // simple checksum of argv
extern GFLAGS_DLL_DECL const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set
extern GFLAGS_DLL_DECL const char* ProgramInvocationShortName(); // basename(argv0)
// ProgramUsage() is thread-safe as long as SetUsageMessage() is only
// called before any threads start.
// ProgramUsage() and VersionString() are thread-safe as long as
// SetUsageMessage() and SetVersionString() are only called before any
// threads start.
extern GFLAGS_DLL_DECL const char* ProgramUsage(); // string set by SetUsageMessage()
extern GFLAGS_DLL_DECL const char* VersionString(); // string set by SetVersionString()
// --------------------------------------------------------------------
// Normally you access commandline flags by just saying "if (FLAGS_foo)"
......@@ -367,6 +334,11 @@ extern GFLAGS_DLL_DECL const char *StringFromEnv(const char *varname, const char
// Thread-hostile; meant to be called before any threads are spawned.
extern GFLAGS_DLL_DECL void SetUsageMessage(const std::string& usage);
// Sets the version string, which is emitted with --version.
// For instance: SetVersionString("1.3");
// Thread-hostile; meant to be called before any threads are spawned.
extern void SetVersionString(const std::string& version);
// Looks for flags in argv and parses them. Rearranges argv to put
// flags first, or removes them entirely if remove_flags is true.
// If a flag is defined more than once in the command line or flag
......@@ -391,10 +363,10 @@ extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv,
// non-flag argument. (If remove_flags is true, will always return 1.)
extern GFLAGS_DLL_DECL uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
bool remove_flags);
// This is actually defined in commandlineflags_reporting.cc.
// This is actually defined in gflags_reporting.cc.
// This function is misnamed (it also handles --version, etc.), but
// it's too late to change that now. :-(
extern GFLAGS_DLL_DECL void HandleCommandLineHelpFlags(); // in commandlineflags_reporting.cc
extern GFLAGS_DLL_DECL void HandleCommandLineHelpFlags(); // in gflags_reporting.cc
// Allow command line reparsing. Disables the error normally
// generated when an unknown flag is found, since it may be found in a
......@@ -408,9 +380,7 @@ extern GFLAGS_DLL_DECL void AllowCommandLineReparsing();
// separate command line argument that follows the flag argument.
// Intended for handling flags from dynamically loaded libraries,
// since their flags are not registered until they are loaded.
// Returns the index (into the original argv) of the first non-flag
// argument. (If remove_flags is true, will always return 1.)
extern GFLAGS_DLL_DECL uint32 ReparseCommandLineNonHelpFlags();
extern GFLAGS_DLL_DECL void ReparseCommandLineNonHelpFlags();
// Clean up memory allocated by flags. This is only needed to reduce
// the quantity of "potentially leaked" reports emitted by memory
......@@ -510,13 +480,6 @@ extern const char kStrippedFlagHelp[];
} \
using fL##shorttype::FLAGS_##name
#define DECLARE_VARIABLE(type, shorttype, name) \
namespace fL##shorttype { \
/* We always want to import declared variables, dll or no */ \
extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; \
} \
using fL##shorttype::FLAGS_##name
// For DEFINE_bool, we want to do the extra check that the passed-in
// value is actually a bool, and not a string or something that can be
// coerced to a bool. These declarations (no definition needed!) will
......@@ -533,7 +496,9 @@ template<typename From> GFLAGS_DLL_DECL double IsBoolFlag(const From& from);
GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
} // namespace fLB
#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name)
// Here are the actual DEFINE_*-macros. The respective DECLARE_*-macros
// are in a separate include, gflags_declare.h, for reducing
// the physical transitive size for DECLARE use.
#define DEFINE_bool(name, val, txt) \
namespace fLB { \
typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
......@@ -541,16 +506,12 @@ GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
} \
DEFINE_VARIABLE(bool, B, name, val, txt)
#define DECLARE_int32(name) DECLARE_VARIABLE(::google::int32, I, name)
#define DEFINE_int32(name,val,txt) DEFINE_VARIABLE(::google::int32, I, name, val, txt)
#define DECLARE_int64(name) DECLARE_VARIABLE(::google::int64, I64, name)
#define DEFINE_int64(name,val,txt) DEFINE_VARIABLE(::google::int64, I64, name, val, txt)
#define DECLARE_uint64(name) DECLARE_VARIABLE(::google::uint64, U64, name)
#define DEFINE_uint64(name,val,txt) DEFINE_VARIABLE(::google::uint64, U64, name, val, txt)
#define DECLARE_double(name) DECLARE_VARIABLE(double, D, name)
#define DEFINE_double(name, val, txt) DEFINE_VARIABLE(double, D, name, val, txt)
// Strings are trickier, because they're not a POD, so we can't
......@@ -579,9 +540,6 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
int value);
} // namespace fLS
#define DECLARE_string(name) namespace fLS { extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; } \
using fLS::FLAGS_##name
// We need to define a var named FLAGS_no##name so people don't define
// --string and --nostring. And we need a temporary place to put val
// so we don't have to evaluate it twice. Two great needs that go
......
// Copyright (c) 2011, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Ray Sidney
// Revamped and reorganized by Craig Silverstein
//
// This is the file that should be included by any file which declares
// command line flag.
#ifndef BASE_COMMANDLINEFLAGS_DECLARE_H_
#define BASE_COMMANDLINEFLAGS_DECLARE_H_
#include <string>
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
// Note: these commands below may look like "#if 1" or "#if 0", but
// that's because they were constructed that way at ./configure time.
// Look at gflags.h.in to see how they're calculated (based on your config).
#if 0
#include <stdint.h> // the normal place uint16_t is defined
#endif
#if 1
#include <sys/types.h> // the normal place u_int16_t is defined
#endif
#if 0
#include <inttypes.h> // a third place for uint16_t or u_int16_t
#endif
namespace google {
#if 0 // the C99 format
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#elif 0 // the BSD format
typedef int32_t int32;
typedef u_int32_t uint32;
typedef int64_t int64;
typedef u_int64_t uint64;
#elif 1 // the windows (vc7) format
typedef __int32 int32;
typedef unsigned __int32 uint32;
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
#error Do not know how to define a 32-bit integer quantity on your system
#endif
}
#define DECLARE_VARIABLE(type, shorttype, name) \
/* We always want to import declared variables, dll or no */ \
namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \
using fL##shorttype::FLAGS_##name
#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name)
#define DECLARE_int32(name) DECLARE_VARIABLE(google::int32, I, name)
#define DECLARE_int64(name) DECLARE_VARIABLE(google::int64, I64, name)
#define DECLARE_uint64(name) DECLARE_VARIABLE(google::uint64, U64, name)
#define DECLARE_double(name) DECLARE_VARIABLE(double, D, name)
#define DECLARE_string(name) \
namespace fLS { typedef std::string clstring; extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; } \
using fLS::FLAGS_##name
#endif // BASE_COMMANDLINEFLAGS_DECLARE_H_
......@@ -135,6 +135,9 @@
<File
RelativePath="..\..\src\windows\gflags\gflags.h">
</File>
<File
RelativePath="..\..\src\windows\gflags\gflags_declare.h">
</File>
<File
RelativePath="..\..\src\windows\gflags\gflags_completions.h">
</File>
......
......@@ -192,6 +192,9 @@
<File
RelativePath="..\..\src\windows\gflags\gflags.h">
</File>
<File
RelativePath="..\..\src\windows\gflags\gflags_declare.h">
</File>
<File
RelativePath="..\..\src\windows\gflags\gflags_completions.h">
</File>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment