diff options
author | Craig Silverstein <csilvers+gflags@google.com> | 2007-10-18 20:08:26 +0000 |
---|---|---|
committer | Craig Silverstein <csilvers+gflags@google.com> | 2007-10-18 20:08:26 +0000 |
commit | 585a44a0c0a99af1256941f3718eade36b6941e7 (patch) | |
tree | 48030efdbeefcf1d8ed809cb34a585bd6961677e /src/gflags.cc | |
parent | eb2083998d18265a001e6bd8bf08d56d27ed8061 (diff) | |
download | gflags-585a44a0c0a99af1256941f3718eade36b6941e7.tar.gz gflags-585a44a0c0a99af1256941f3718eade36b6941e7.tar.bz2 gflags-585a44a0c0a99af1256941f3718eade36b6941e7.zip |
Thu Oct 18 11:33:20 2007 Google Inc. <opensource@google.com>
* google-gflags: version 0.7
* Deal even more correctly with libpthread not linked in (csilvers)
* Add STRIP_LOG, an improved DO_NOT_SHOW_COMMANDLINE_HELP (sioffe)
* Be more accurate printing default flag values in --help (dsturtevant)
* Reduce .o file size a bit by using shorter namespace names (jeff)
* Use relative install path, so 'setup.py --home' works (csilvers)
* Notice when a boolean flag has a non-boolean default (bnmouli)
* Broaden --helpshort to match foo-main.cc and foo_main.cc (hendrie)
* Fix "no modules match" message for --helpshort, etc (hendrie)
git-svn-id: https://gflags.googlecode.com/svn/trunk@19 6586e3c6-dcc4-952a-343f-ff74eb82781d
Diffstat (limited to 'src/gflags.cc')
-rw-r--r-- | src/gflags.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/gflags.cc b/src/gflags.cc index 1210434..c14e120 100644 --- a/src/gflags.cc +++ b/src/gflags.cc @@ -93,6 +93,13 @@ _START_GOOGLE_NAMESPACE_ static const char kError[] = "ERROR: "; +// The help message indicating that the commandline flag has been +// 'stripped'. It will not show up when doing "-help" and its +// variants. The flag is stripped if STRIP_FLAG_HELP is set to 1 +// before including base/commandlineflags.h (or in +// base/global_strip_options.h). + +const char kStrippedFlagHelp[] = "\001\002\003\004 (unknown) \004\003\002\001"; // Indicates that undefined options are to be ignored. // Enables deferred processing of flags in dynamically loaded libraries. @@ -637,7 +644,20 @@ void FlagRegistry::InitGlobalRegistry() { } // We want to use pthread_once here, for safety, but have to worry about -// whether libpthread is linked in or not. +// whether libpthread is linked in or not. We declare a weak version of +// the function, so we'll always compile (if the weak version is the only +// one that ends up existing, then pthread_once will be equal to NULL). +#ifdef HAVE___ATTRIBUTE__ + // __THROW is defined in glibc systems. It means, counter-intuitively, + // "This function will never throw an exception." It's an optional + // optimization tool, but we may need to use it to match glibc prototypes. +# ifndef __THROW // I guess we're not on a glibc system +# define __THROW // __THROW is just an optimization, so ok to make it "" +# endif +extern "C" int pthread_once(pthread_once_t *, void (*)(void)) + __THROW __attribute__((weak)); +#endif + FlagRegistry* FlagRegistry::GlobalRegistry() { if (pthread_once) { // means we're running with pthreads pthread_once(&global_registry_once_, &FlagRegistry::InitGlobalRegistry); @@ -648,6 +668,14 @@ FlagRegistry* FlagRegistry::GlobalRegistry() { return global_registry_; } + +void FlagsTypeWarn(const char *name) { + fprintf(stderr, "ERROR: Flag %s is of type bool, " + "but its default value is not a boolean.\n", name); + // This can (and one day should) become a compilations error + //commandlineflags_exitfunc(1); // almost certainly exit() +} + // -------------------------------------------------------------------- // FlagRegisterer // This class exists merely to have a global constructor (the |