| Index: third_party/gflags/gen/posix/include/gflags/gflags.h
|
| diff --git a/third_party/gflags/gen/posix/include/gflags/gflags.h b/third_party/gflags/gen/posix/include/gflags/gflags.h
|
| index 5d07b30b90aece9fc2ba964d910d7a224f1ddada..0db38f5c86826b31eeb1af15ea6bec97dafdbfd8 100644
|
| --- a/third_party/gflags/gen/posix/include/gflags/gflags.h
|
| +++ b/third_party/gflags/gen/posix/include/gflags/gflags.h
|
| @@ -28,7 +28,6 @@
|
| // 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
|
| @@ -52,8 +51,8 @@
|
| // if (FLAGS_verbose) printf("Records %d-%d\n", FLAGS_start, FLAGS_end);
|
| // }
|
| //
|
| -// Then, at the command-line:
|
| -// ./foo --noverbose --start=5 --end=100
|
| +// Then, at the command-line:
|
| +// ./foo --noverbose --start=5 --end=100
|
| //
|
| // For more details, see
|
| // doc/gflags.html
|
| @@ -76,53 +75,27 @@
|
| // other thread is writing to the variable or calling non-const
|
| // methods of this class.
|
|
|
| -#ifndef GOOGLE_GFLAGS_H_
|
| -#define GOOGLE_GFLAGS_H_
|
| +#ifndef GFLAGS_GFLAGS_H_
|
| +#define GFLAGS_GFLAGS_H_
|
|
|
| #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 1
|
| -#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 1
|
| -#include <inttypes.h> // a third place for uint16_t or u_int16_t
|
| -#endif
|
| +#include "gflags_declare.h" // IWYU pragma: export
|
|
|
| -namespace google {
|
| -
|
| -#if 1 // the C99 format
|
| -typedef int32_t int32;
|
| -typedef uint32_t uint32;
|
| -typedef int64_t int64;
|
| -typedef uint64_t uint64;
|
| -#elif 1 // the BSD format
|
| -typedef int32_t int32;
|
| -typedef u_int32_t uint32;
|
| -typedef int64_t int64;
|
| -typedef u_int64_t uint64;
|
| -#elif 0 // 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
|
| +
|
| +// We always want to export variables defined in user code
|
| +#ifndef GFLAGS_DLL_DEFINE_FLAG
|
| +# ifdef _MSC_VER
|
| +# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
|
| +# else
|
| +# define GFLAGS_DLL_DEFINE_FLAG
|
| +# endif
|
| #endif
|
|
|
| -// TODO(kjellander): update generated .h's for new gflags.
|
| -// https://code.google.com/p/webrtc/issues/detail?id=2251
|
| -extern const char* VersionString();
|
| -extern void SetVersionString(const std::string& version);
|
| +
|
| +namespace GFLAGS_NAMESPACE {
|
| +
|
|
|
| // --------------------------------------------------------------------
|
| // To actually define a flag in a file, use DEFINE_bool,
|
| @@ -153,18 +126,17 @@ extern void SetVersionString(const std::string& version);
|
| // Returns true if successfully registered, false if not (because the
|
| // first argument doesn't point to a command-line flag, or because a
|
| // validator is already registered for this flag).
|
| -bool RegisterFlagValidator(const bool* flag,
|
| - bool (*validate_fn)(const char*, bool));
|
| -bool RegisterFlagValidator(const int32* flag,
|
| - bool (*validate_fn)(const char*, int32));
|
| -bool RegisterFlagValidator(const int64* flag,
|
| - bool (*validate_fn)(const char*, int64));
|
| -bool RegisterFlagValidator(const uint64* flag,
|
| - bool (*validate_fn)(const char*, uint64));
|
| -bool RegisterFlagValidator(const double* flag,
|
| - bool (*validate_fn)(const char*, double));
|
| -bool RegisterFlagValidator(const std::string* flag,
|
| - bool (*validate_fn)(const char*, const std::string&));
|
| +extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool* flag, bool (*validate_fn)(const char*, bool));
|
| +extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32* flag, bool (*validate_fn)(const char*, int32));
|
| +extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64* flag, bool (*validate_fn)(const char*, int64));
|
| +extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64* flag, bool (*validate_fn)(const char*, uint64));
|
| +extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const double* flag, bool (*validate_fn)(const char*, double));
|
| +extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const std::string* flag, bool (*validate_fn)(const char*, const std::string&));
|
| +
|
| +// Convenience macro for the registration of a flag validator
|
| +#define DEFINE_validator(name, validator) \
|
| + static const bool name##_validator_registered = \
|
| + GFLAGS_NAMESPACE::RegisterFlagValidator(&FLAGS_##name, validator)
|
|
|
|
|
| // --------------------------------------------------------------------
|
| @@ -177,49 +149,56 @@ bool RegisterFlagValidator(const std::string* flag,
|
| // In addition to accessing flags, you can also access argv[0] (the program
|
| // name) and argv (the entire commandline), which we sock away a copy of.
|
| // These variables are static, so you should only set them once.
|
| -
|
| +//
|
| +// No need to export this data only structure from DLL, avoiding VS warning 4251.
|
| struct CommandLineFlagInfo {
|
| - std::string name; // the name of the flag
|
| - std::string type; // the type of the flag: int32, etc
|
| - std::string description; // the "help text" associated with the flag
|
| - std::string current_value; // the current value, as a string
|
| - std::string default_value; // the default value, as a string
|
| - std::string filename; // 'cleaned' version of filename holding the flag
|
| - bool has_validator_fn; // true if RegisterFlagValidator called on flag
|
| - bool is_default; // true if the flag has the default value and
|
| - // has not been set explicitly from the cmdline
|
| - // or via SetCommandLineOption
|
| - const void* flag_ptr;
|
| -
|
| + std::string name; // the name of the flag
|
| + std::string type; // the type of the flag: int32, etc
|
| + std::string description; // the "help text" associated with the flag
|
| + std::string current_value; // the current value, as a string
|
| + std::string default_value; // the default value, as a string
|
| + std::string filename; // 'cleaned' version of filename holding the flag
|
| + bool has_validator_fn; // true if RegisterFlagValidator called on this flag
|
| + bool is_default; // true if the flag has the default value and
|
| + // has not been set explicitly from the cmdline
|
| + // or via SetCommandLineOption
|
| + const void* flag_ptr; // pointer to the flag's current value (i.e. FLAGS_foo)
|
| };
|
|
|
| // Using this inside of a validator is a recipe for a deadlock.
|
| -// TODO(wojtekm) Fix locking when validators are running, to make it safe to
|
| +// TODO(user) 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
|
| -extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
|
| -// These two are actually defined in commandlineflags_reporting.cc.
|
| -extern void ShowUsageWithFlags(const char *argv0); // what --help does
|
| -extern void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
|
| +// gflags_unittest.sh
|
| +extern GFLAGS_DLL_DECL void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
|
| +// 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);
|
|
|
| // Create a descriptive string for a flag.
|
| // Goes to some trouble to make pretty line breaks.
|
| -extern std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
|
| +extern GFLAGS_DLL_DECL std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
|
|
|
| // Thread-hostile; meant to be called before any threads are spawned.
|
| -extern void SetArgv(int argc, const char** argv);
|
| +extern GFLAGS_DLL_DECL void SetArgv(int argc, const char** argv);
|
| +
|
| // The following functions are thread-safe as long as SetArgv() is
|
| // only called before any threads start.
|
| -extern const std::vector<std::string>& GetArgvs(); // all of argv as a vector
|
| -extern const char* GetArgv(); // all of argv as a string
|
| -extern const char* GetArgv0(); // only argv0
|
| -extern uint32 GetArgvSum(); // simple checksum of argv
|
| -extern const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set
|
| -extern const char* ProgramInvocationShortName(); // basename(argv0)
|
| +extern GFLAGS_DLL_DECL const std::vector<std::string>& GetArgvs();
|
| +extern GFLAGS_DLL_DECL const char* GetArgv(); // all of argv as a string
|
| +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.
|
| -extern const char* ProgramUsage(); // string set by SetUsageMessage()
|
| +extern GFLAGS_DLL_DECL const char* ProgramUsage(); // string set by SetUsageMessage()
|
| +
|
| +// VersionString() is thread-safe as long as SetVersionString() is only
|
| +// called before any threads start.
|
| +extern GFLAGS_DLL_DECL const char* VersionString(); // string set by SetVersionString()
|
| +
|
|
|
|
|
| // --------------------------------------------------------------------
|
| @@ -232,19 +211,18 @@ extern const char* ProgramUsage(); // string set by SetUsageMessage()
|
|
|
| // Return true iff the flagname was found.
|
| // OUTPUT is set to the flag's value, or unchanged if we return false.
|
| -extern bool GetCommandLineOption(const char* name, std::string* OUTPUT);
|
| +extern GFLAGS_DLL_DECL bool GetCommandLineOption(const char* name, std::string* OUTPUT);
|
|
|
| // Return true iff the flagname was found. OUTPUT is set to the flag's
|
| // CommandLineFlagInfo or unchanged if we return false.
|
| -extern bool GetCommandLineFlagInfo(const char* name,
|
| - CommandLineFlagInfo* OUTPUT);
|
| +extern GFLAGS_DLL_DECL bool GetCommandLineFlagInfo(const char* name, CommandLineFlagInfo* OUTPUT);
|
|
|
| // Return the CommandLineFlagInfo of the flagname. exit() if name not found.
|
| // Example usage, to check if a flag's value is currently the default value:
|
| // if (GetCommandLineFlagInfoOrDie("foo").is_default) ...
|
| -extern CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
|
| +extern GFLAGS_DLL_DECL CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
|
|
|
| -enum FlagSettingMode {
|
| +enum GFLAGS_DLL_DECL FlagSettingMode {
|
| // update the flag's value (can call this multiple times).
|
| SET_FLAGS_VALUE,
|
| // update the flag's value, but *only if* it has not yet been updated
|
| @@ -264,9 +242,8 @@ enum FlagSettingMode {
|
| // non-empty else.
|
|
|
| // SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
|
| -extern std::string SetCommandLineOption(const char* name, const char* value);
|
| -extern std::string SetCommandLineOptionWithMode(const char* name, const char* value,
|
| - FlagSettingMode set_mode);
|
| +extern GFLAGS_DLL_DECL std::string SetCommandLineOption (const char* name, const char* value);
|
| +extern GFLAGS_DLL_DECL std::string SetCommandLineOptionWithMode(const char* name, const char* value, FlagSettingMode set_mode);
|
|
|
|
|
| // --------------------------------------------------------------------
|
| @@ -287,14 +264,17 @@ extern std::string SetCommandLineOptionWithMode(const char* name, const char* va
|
| // // without worrying about restoring the FLAG values.
|
| // }
|
| //
|
| -// Note: This class is marked with __attribute__((unused)) because all the
|
| -// work is done in the constructor and destructor, so in the standard
|
| +// Note: This class is marked with GFLAGS_ATTRIBUTE_UNUSED because all
|
| +// the work is done in the constructor and destructor, so in the standard
|
| // usage example above, the compiler would complain that it's an
|
| // unused variable.
|
| //
|
| -// This class is thread-safe.
|
| +// This class is thread-safe. However, its destructor writes to
|
| +// exactly the set of flags that have changed value during its
|
| +// lifetime, so concurrent _direct_ access to those flags
|
| +// (i.e. FLAGS_foo instead of {Get,Set}CommandLineOption()) is unsafe.
|
|
|
| -class FlagSaver {
|
| +class GFLAGS_DLL_DECL FlagSaver {
|
| public:
|
| FlagSaver();
|
| ~FlagSaver();
|
| @@ -304,24 +284,23 @@ class FlagSaver {
|
|
|
| FlagSaver(const FlagSaver&); // no copying!
|
| void operator=(const FlagSaver&);
|
| -} __attribute__ ((unused));
|
| +}__attribute((unused));
|
|
|
| // --------------------------------------------------------------------
|
| // Some deprecated or hopefully-soon-to-be-deprecated functions.
|
|
|
| // This is often used for logging. TODO(csilvers): figure out a better way
|
| -extern std::string CommandlineFlagsIntoString();
|
| +extern GFLAGS_DLL_DECL std::string CommandlineFlagsIntoString();
|
| // Usually where this is used, a FlagSaver should be used instead.
|
| -extern bool ReadFlagsFromString(const std::string& flagfilecontents,
|
| - const char* prog_name,
|
| - bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
| +extern GFLAGS_DLL_DECL
|
| +bool ReadFlagsFromString(const std::string& flagfilecontents,
|
| + const char* prog_name,
|
| + bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
|
|
| // These let you manually implement --flagfile functionality.
|
| // DEPRECATED.
|
| -extern bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
|
| -extern bool SaveCommandFlags(); // actually defined in google.cc !
|
| -extern bool ReadFromFlagsFile(const std::string& filename, const char* prog_name,
|
| - bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
| +extern GFLAGS_DLL_DECL bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
|
| +extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string& filename, const char* prog_name, bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
|
|
|
|
| // --------------------------------------------------------------------
|
| @@ -332,16 +311,16 @@ extern bool ReadFromFlagsFile(const std::string& filename, const char* prog_name
|
| // Otherwise, return the value. NOTE: for booleans, for true use
|
| // 't' or 'T' or 'true' or '1', for false 'f' or 'F' or 'false' or '0'.
|
|
|
| -extern bool BoolFromEnv(const char *varname, bool defval);
|
| -extern int32 Int32FromEnv(const char *varname, int32 defval);
|
| -extern int64 Int64FromEnv(const char *varname, int64 defval);
|
| -extern uint64 Uint64FromEnv(const char *varname, uint64 defval);
|
| -extern double DoubleFromEnv(const char *varname, double defval);
|
| -extern const char *StringFromEnv(const char *varname, const char *defval);
|
| +extern GFLAGS_DLL_DECL bool BoolFromEnv(const char *varname, bool defval);
|
| +extern GFLAGS_DLL_DECL int32 Int32FromEnv(const char *varname, int32 defval);
|
| +extern GFLAGS_DLL_DECL int64 Int64FromEnv(const char *varname, int64 defval);
|
| +extern GFLAGS_DLL_DECL uint64 Uint64FromEnv(const char *varname, uint64 defval);
|
| +extern GFLAGS_DLL_DECL double DoubleFromEnv(const char *varname, double defval);
|
| +extern GFLAGS_DLL_DECL const char *StringFromEnv(const char *varname, const char *defval);
|
|
|
|
|
| // --------------------------------------------------------------------
|
| -// The next two functions parse commandlineflags from main():
|
| +// The next two functions parse gflags from main():
|
|
|
| // Set the "usage" message for this program. For example:
|
| // string usage("This program does nothing. Sample usage:\n");
|
| @@ -349,7 +328,13 @@ extern const char *StringFromEnv(const char *varname, const char *defval);
|
| // SetUsageMessage(usage);
|
| // Do not include commandline flags in the usage: we do that for you!
|
| // Thread-hostile; meant to be called before any threads are spawned.
|
| -extern void SetUsageMessage(const std::string& usage);
|
| +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 GFLAGS_DLL_DECL 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.
|
| @@ -358,8 +343,7 @@ extern void SetUsageMessage(const std::string& usage);
|
| // of the first non-flag argument.
|
| // See top-of-file for more details on this function.
|
| #ifndef SWIG // In swig, use ParseCommandLineFlagsScript() instead.
|
| -extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
|
| - bool remove_flags);
|
| +extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv, bool remove_flags);
|
| #endif
|
|
|
|
|
| @@ -373,18 +357,18 @@ extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
|
| // defined more than once in the command line or flag file, the last
|
| // definition is used. Returns the index (into argv) of the first
|
| // 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.
|
| +extern GFLAGS_DLL_DECL uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv, bool remove_flags);
|
| +
|
| +// 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 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
|
| // later parse. Thread-hostile; meant to be called before any threads
|
| // are spawned.
|
| -extern void AllowCommandLineReparsing();
|
| +extern GFLAGS_DLL_DECL void AllowCommandLineReparsing();
|
|
|
| // Reparse the flags that have not yet been recognized. Only flags
|
| // registered since the last parse will be recognized. Any flag value
|
| @@ -392,19 +376,18 @@ extern 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 void 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
|
| // debugging tools such as valgrind. It is not required for normal
|
| -// operation, or for the perftools heap-checker. It must only be called
|
| -// when the process is about to exit, and all threads that might
|
| -// access flags are quiescent. Referencing flags after this is called
|
| -// will have unexpected consequences. This is not safe to run when
|
| -// multiple threads might be running: the function is thread-hostile.
|
| -extern void ShutDownCommandLineFlags();
|
| +// operation, or for the google perftools heap-checker. It must only
|
| +// be called when the process is about to exit, and all threads that
|
| +// might access flags are quiescent. Referencing flags after this is
|
| +// called will have unexpected consequences. This is not safe to run
|
| +// when multiple threads might be running: the function is
|
| +// thread-hostile.
|
| +extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags();
|
|
|
|
|
| // --------------------------------------------------------------------
|
| @@ -435,7 +418,7 @@ extern void ShutDownCommandLineFlags();
|
| // directly. The idea is that DEFINE puts the flag in the weird
|
| // namespace, and DECLARE imports the flag from there into the current
|
| // namespace. The net result is to force people to use DECLARE to get
|
| -// access to a flag, rather than saying "extern bool FLAGS_whatever;"
|
| +// access to a flag, rather than saying "extern GFLAGS_DLL_DECL bool FLAGS_whatever;"
|
| // or some such instead. We want this so we can put extra
|
| // functionality (like sanity-checking) in DECLARE if we want, and
|
| // make sure it is picked up everywhere.
|
| @@ -444,29 +427,30 @@ extern void ShutDownCommandLineFlags();
|
| // people can't DECLARE_int32 something that they DEFINE_bool'd
|
| // elsewhere.
|
|
|
| -class FlagRegisterer {
|
| +class GFLAGS_DLL_DECL FlagRegisterer {
|
| public:
|
| FlagRegisterer(const char* name, const char* type,
|
| const char* help, const char* filename,
|
| void* current_storage, void* defvalue_storage);
|
| };
|
|
|
| -extern bool FlagsTypeWarn(const char *name);
|
| -
|
| // If your application #defines STRIP_FLAG_HELP to a non-zero value
|
| // before #including this file, we remove the help message from the
|
| // binary file. This can reduce the size of the resulting binary
|
| // somewhat, and may also be useful for security reasons.
|
|
|
| -extern const char kStrippedFlagHelp[];
|
| +extern GFLAGS_DLL_DECL const char kStrippedFlagHelp[];
|
| +
|
| +
|
| +} // namespace GFLAGS_NAMESPACE
|
|
|
| -}
|
|
|
| #ifndef SWIG // In swig, ignore the main flag declarations
|
|
|
| #if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
|
| // Need this construct to avoid the 'defined but not used' warning.
|
| -#define MAYBE_STRIPPED_HELP(txt) (false ? (txt) : ::google::kStrippedFlagHelp)
|
| +#define MAYBE_STRIPPED_HELP(txt) \
|
| + (false ? (txt) : GFLAGS_NAMESPACE::kStrippedFlagHelp)
|
| #else
|
| #define MAYBE_STRIPPED_HELP(txt) txt
|
| #endif
|
| @@ -482,21 +466,16 @@ extern const char kStrippedFlagHelp[];
|
| // FLAGS_no<name>. This serves the second purpose of assuring a
|
| // compile error if someone tries to define a flag named no<name>
|
| // which is illegal (--foo and --nofoo both affect the "foo" flag).
|
| -#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
|
| - namespace fL##shorttype { \
|
| - static const type FLAGS_nono##name = value; \
|
| - type FLAGS_##name = FLAGS_nono##name; \
|
| - type FLAGS_no##name = FLAGS_nono##name; \
|
| - static ::google::FlagRegisterer o_##name( \
|
| - #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
|
| - &FLAGS_##name, &FLAGS_no##name); \
|
| - } \
|
| - using fL##shorttype::FLAGS_##name
|
| -
|
| -#define DECLARE_VARIABLE(type, shorttype, name) \
|
| - namespace fL##shorttype { \
|
| - extern type FLAGS_##name; \
|
| - } \
|
| +#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
|
| + namespace fL##shorttype { \
|
| + static const type FLAGS_nono##name = value; \
|
| + /* We always want to export defined variables, dll or no */ \
|
| + GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
|
| + type FLAGS_no##name = FLAGS_nono##name; \
|
| + static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
| + #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
|
| + &FLAGS_##name, &FLAGS_no##name); \
|
| + } \
|
| using fL##shorttype::FLAGS_##name
|
|
|
| // For DEFINE_bool, we want to do the extra check that the passed-in
|
| @@ -506,34 +485,39 @@ extern const char kStrippedFlagHelp[];
|
| // We'll use 'sizeof(IsBool(val))' to distinguish. This code requires
|
| // that the compiler have different sizes for bool & double. Since
|
| // this is not guaranteed by the standard, we check it with a
|
| -// compile-time assert (msg[-1] will give a compile-time error).
|
| +// COMPILE_ASSERT.
|
| namespace fLB {
|
| struct CompileAssert {};
|
| typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[
|
| (sizeof(double) != sizeof(bool)) ? 1 : -1];
|
| -template<typename From> double IsBoolFlag(const From& from);
|
| -bool IsBoolFlag(bool from);
|
| +template<typename From> double GFLAGS_DLL_DECL IsBoolFlag(const From& from);
|
| +GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
|
| } // namespace fLB
|
|
|
| -#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name)
|
| -#define DEFINE_bool(name, val, txt) \
|
| - namespace fLB { \
|
| - typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
|
| - (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \
|
| - } \
|
| +// 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[ \
|
| + (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double))? 1: -1]; \
|
| + } \
|
| 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 DEFINE_int32(name, val, txt) \
|
| + DEFINE_VARIABLE(GFLAGS_NAMESPACE::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 DEFINE_int64(name, val, txt) \
|
| + DEFINE_VARIABLE(GFLAGS_NAMESPACE::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 DEFINE_uint64(name,val, txt) \
|
| + DEFINE_VARIABLE(GFLAGS_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)
|
| +#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
|
| // construct them at static-initialization time (instead they get
|
| @@ -543,11 +527,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) {
|
| @@ -561,9 +540,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
|
| @@ -578,10 +554,10 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
| clstring* const FLAGS_no##name = ::fLS:: \
|
| dont_pass0toDEFINE_string(s_##name[0].s, \
|
| val); \
|
| - static ::google::FlagRegisterer o_##name( \
|
| + static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
| #name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
|
| s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
|
| - extern clstring& FLAGS_##name; \
|
| + extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
|
| using fLS::FLAGS_##name; \
|
| clstring& FLAGS_##name = *FLAGS_no##name; \
|
| } \
|
| @@ -589,4 +565,9 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
|
|
| #endif // SWIG
|
|
|
| -#endif // GOOGLE_GFLAGS_H_
|
| +
|
| +// Import gflags library symbols into alternative/deprecated namespace(s)
|
| +#include "gflags_gflags.h"
|
| +
|
| +
|
| +#endif // GFLAGS_GFLAGS_H_
|
|
|