Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1384)

Unified Diff: third_party/gflags/gen/win/include/gflags/gflags.h

Issue 1679263002: Switch third_party/gflags to use updated GitHub repo. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add myself to owners Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/gflags/gen/win/include/gflags/gflags.h
diff --git a/third_party/gflags/gen/win/include/gflags/gflags.h b/third_party/gflags/gen/win/include/gflags/gflags.h
index 6af969b35381afa158f3647ba67638892adeec2c..357eec6be7ce2f714db9c5e9cdbab78b113337f6 100644
--- a/third_party/gflags/gen/win/include/gflags/gflags.h
+++ b/third_party/gflags/gen/win/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,76 +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 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_declare.h" // IWYU pragma: export
-// Annoying stuff for windows -- makes sure clients can import these functions
-#if defined(_WIN32)
-# ifndef GFLAGS_DLL_DECL
-# define GFLAGS_DLL_DECL __declspec(dllimport)
-# endif
-# ifndef GFLAGS_DLL_DECLARE_FLAG
-# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
-# endif
-# ifndef GFLAGS_DLL_DEFINE_FLAG
-# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
-# endif
-#else
-# ifndef GFLAGS_DLL_DECL
-# define GFLAGS_DLL_DECL
-# endif
-# ifndef GFLAGS_DLL_DECLARE_FLAG
-# define GFLAGS_DLL_DECLARE_FLAG
-# endif
-# ifndef GFLAGS_DLL_DEFINE_FLAG
-# define GFLAGS_DLL_DEFINE_FLAG
-# endif
-#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
+// 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,
@@ -176,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).
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool* flag,
- bool (*validate_fn)(const char*, bool));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32* flag,
- bool (*validate_fn)(const char*, int32));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64* flag,
- bool (*validate_fn)(const char*, int64));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64* flag,
- bool (*validate_fn)(const char*, uint64));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const double* flag,
- bool (*validate_fn)(const char*, double));
-GFLAGS_DLL_DECL 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)
// --------------------------------------------------------------------
@@ -200,28 +149,29 @@ GFLAGS_DLL_DECL 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.
-
-struct GFLAGS_DLL_DECL 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;
+//
+// 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 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
+// 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);
@@ -231,17 +181,24 @@ extern GFLAGS_DLL_DECL std::string DescribeOneFlag(const CommandLineFlagInfo& fl
// Thread-hostile; meant to be called before any threads are spawned.
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 GFLAGS_DLL_DECL const std::vector<std::string>& GetArgvs(); // all of argv as a vector
-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 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 GFLAGS_DLL_DECL 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()
+
// --------------------------------------------------------------------
@@ -258,8 +215,7 @@ extern GFLAGS_DLL_DECL bool GetCommandLineOption(const char* name, std::string*
// Return true iff the flagname was found. OUTPUT is set to the flag's
// CommandLineFlagInfo or unchanged if we return false.
-extern GFLAGS_DLL_DECL 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:
@@ -286,9 +242,8 @@ enum GFLAGS_DLL_DECL FlagSettingMode {
// non-empty else.
// SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
-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);
+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);
// --------------------------------------------------------------------
@@ -309,12 +264,15 @@ extern GFLAGS_DLL_DECL std::string SetCommandLineOptionWithMode(const char* name
// // 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 GFLAGS_DLL_DECL FlagSaver {
public:
@@ -326,7 +284,7 @@ class GFLAGS_DLL_DECL FlagSaver {
FlagSaver(const FlagSaver&); // no copying!
void operator=(const FlagSaver&);
-} ;
+};
// --------------------------------------------------------------------
// Some deprecated or hopefully-soon-to-be-deprecated functions.
@@ -334,16 +292,15 @@ class GFLAGS_DLL_DECL FlagSaver {
// This is often used for logging. TODO(csilvers): figure out a better way
extern GFLAGS_DLL_DECL std::string CommandlineFlagsIntoString();
// Usually where this is used, a FlagSaver should be used instead.
-extern GFLAGS_DLL_DECL 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 GFLAGS_DLL_DECL bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
-extern GFLAGS_DLL_DECL bool SaveCommandFlags(); // actually defined in google.cc !
-extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string& filename, const char* prog_name,
- bool errors_are_fatal); // uses SET_FLAGS_VALUE
+extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string& filename, const char* prog_name, bool errors_are_fatal); // uses SET_FLAGS_VALUE
// --------------------------------------------------------------------
@@ -363,7 +320,7 @@ extern GFLAGS_DLL_DECL const char *StringFromEnv(const char *varname, const char
// --------------------------------------------------------------------
-// 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");
@@ -373,14 +330,20 @@ 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 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.
// If a flag is defined more than once in the command line or flag
-// file, the last definition is used.
+// file, the last definition is used. Returns the index (into argv)
+// of the first non-flag argument.
// See top-of-file for more details on this function.
#ifndef SWIG // In swig, use ParseCommandLineFlagsScript() instead.
-extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv,
- bool remove_flags);
+extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv, bool remove_flags);
#endif
@@ -390,15 +353,16 @@ extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv,
// changing default values for some FLAGS (via
// e.g. SetCommandLineOptionWithMode calls) between the time of
// command line parsing and the time of dumping help information for
-// the flags as a result of command line parsing.
-// If a flag is defined more than once in the command line or flag
-// file, the last definition is used.
-extern GFLAGS_DLL_DECL uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
- bool remove_flags);
-// This is actually defined in commandlineflags_reporting.cc.
+// the flags as a result of command line parsing. If a flag is
+// 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 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 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
@@ -406,10 +370,10 @@ extern GFLAGS_DLL_DECL void HandleCommandLineHelpFlags(); // in commandlinefla
// are spawned.
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 must be provided as part of the argument using "=",
-// not as a separate command line argument that follows the flag argument.
+// Reparse the flags that have not yet been recognized. Only flags
+// registered since the last parse will be recognized. Any flag value
+// must be provided as part of the argument using "=", not as a
+// 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.
extern GFLAGS_DLL_DECL void ReparseCommandLineNonHelpFlags();
@@ -417,11 +381,12 @@ 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.
+// 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();
@@ -453,7 +418,7 @@ extern GFLAGS_DLL_DECL 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.
@@ -469,22 +434,23 @@ class GFLAGS_DLL_DECL FlagRegisterer {
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) : kStrippedFlagHelp)
+#define MAYBE_STRIPPED_HELP(txt) \
+ (false ? (txt) : GFLAGS_NAMESPACE::kStrippedFlagHelp)
#else
#define MAYBE_STRIPPED_HELP(txt) txt
#endif
@@ -500,23 +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; \
- /* 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 ::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 { \
- /* We always want to import declared variables, dll or no */ \
- extern GFLAGS_DLL_DECLARE_FLAG 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
@@ -526,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> GFLAGS_DLL_DECL double IsBoolFlag(const From& 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
@@ -563,11 +527,6 @@ GFLAGS_DLL_DECL 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) {
@@ -581,13 +540,13 @@ 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
// great together!
+// The weird 'using' + 'extern' inside the fLS namespace is to work around
+// an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10. See
+// http://code.google.com/p/google-gflags/issues/detail?id=20
#define DEFINE_string(name, val, txt) \
namespace fLS { \
using ::fLS::clstring; \
@@ -595,13 +554,20 @@ 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)); \
- GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name = *FLAGS_no##name; \
+ extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
+ using fLS::FLAGS_##name; \
+ clstring& FLAGS_##name = *FLAGS_no##name; \
} \
using fLS::FLAGS_##name
#endif // SWIG
-#endif // GOOGLE_GFLAGS_H_
+
+// Import gflags library symbols into alternative/deprecated namespace(s)
+#include "gflags_gflags.h"
+
+
+#endif // GFLAGS_GFLAGS_H_
« no previous file with comments | « third_party/gflags/gen/posix/include/private/config.h ('k') | third_party/gflags/gen/win/include/gflags/gflags_completions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698