hemprasad / gflags

Automatically exported from code.google.com/p/gflags
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Feature request: macro to detect if flag is set or not #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice if detecting a flag is set or not can be done using a Macro

Something like this:

DEFINE_bool(using_fancy_log, true, "should we use some fancy log?")
#ifdef FLAG_IS_DEFINED_using_fancy_log
#include "some/fancy/lib.h"
if(using_fancy_log){
  call_fancy_lib_functions()
}
#endif

This way if we don't want use the feature at all, we can simply comment out the 
#DEFINE_bool line.

Original issue reported on code.google.com by cnye...@gmail.com on 5 Jun 2013 at 5:59

GoogleCodeExporter commented 9 years ago
Hi, thanks for sharing your idea. However, I object the value of this use case 
might not be very clean and desired by everyone. You could also simply define 
your own macros/build time preprocessor switches and surround also the 
DEFINE_flag macro by the respective #ifdef directives.

#ifdef USE_FANCY_LOG
DEFINE_bool(....)
#endif

or hide this in your own wrapper macro for the gflags DEFINE_flag macros...

Original comment by andreas....@gmail.com on 5 Jun 2013 at 6:42

GoogleCodeExporter commented 9 years ago
Wrapping existing DEFINE macro is a good idea. Thank you for the hint.

Original comment by cnye...@gmail.com on 5 Jun 2013 at 6:51