The UDS Collection

Configuring UDS

back to main page

UDS Flags

To use some of the features UDS provides, you have to configure the library in your program. This should to be done at compile time. You do this by defining the variable uds::flags.
That might look like the following:

#include <uds/uds.hh>

// configure UDS
uds::uds_flags_t uds::flags = uds::leak_check | uds::summon_zombies;

The flags will be 0 if you do not override them.

The available flags are:
force core dumps when an UDS exception is thrown
check for memory leaks
create zombie objects
log all memory [de]allocations to stderr
rename cores that are dumped by UDS exceptions
generate always a backtrace when a UDS exception is thrown

Note that starting with version 0.9.5 uds::flags is not constant anymore. You can now change flags at runtime. This is especially useful for the force_core_dumps and log_allocs flags. I recommend you use a VRemember object to make sure the value gets restored in case of an exception. Don't change the leak_check flag though or you will get funny results.

If you don't want to set any flags, you don't have to provide uds::flags. However, UDS defines global new and delete operators (as weak symbols). If you don't set any flags, there is still a small performance overhead. Fortunately, there is a workaround.
UDS comes with a source file ([prefix]/share/uds/ that, when added to your program, will #include config.h if present and set the uds flags according to present #defines. Additionally, when it is not necessary to use UDS new / delete operators, the original new and delete operators are restored.
Note that if the standard operators are restored, you won't be able to switch on leak_check, summon_zombies, or log_allocs at runtime.

If you want to use the debugging facilities during development, and run your releases at full speed, add to your project and add at least the following line to your


This is a m4 macro which adds a configure check for each flag. The default options depend on whether debugging is enabled. This check is done by UDS_DEBUG, a prerequisite macro for UDS_CHECK_FLAGS.
If you use your own --enable-debug option, you might want to use the UDS_CHECK_FLAGS_NB macro instead, which does not depend on other macros. All flag switches default to 'no'.

M4 macros

There are a some other useful m4 macros provided my UDS. Have a look at the UDS for a few examples.

Checks that libuds is installed on your system. If not, a short message and a link to the download page are printed.
Same as above, but it is also checked for libudsthread.
Checks for specific versions of UDS.
Examples: UDS_CHECK_VERSION(0.9.5) checks for a version >= 0.9.5, and UDS_CHECK_VERSION(0.9.5,1.0.0) checks for a version >= 0.9.5 <= 1.0.0
Adds the configure options --with-extra-libs and --with-extra-includes. You can pass space separated lists of paths to the options to specify extra library and include paths.
You have to use the UDS_FL_GEN macro at the end of your file to make this work.
Adds the --enable-debug option which is used to enable generation of debugging information. If you want to use a different debug option than -g, pass it as argument to the macro. Default settings of several other switches (generated by UDS macros) depend on this option.
Adds the --enable-static option. If enabled, the -static option is used, and STATIC is defined in config.h. Default is 'no'.
Adds two options, --enable-optimization and --enable-arch. The --enable-optimization is used to toggle optimization options. It is possible to optimize explicitly for speed or size by using --enable-optimization=speed|size. Additional compiler options for standard, speed, and size optimization can be passed as first, second, and third argument to the macro. I use usually something like UDS_CHECK_OPTIMIZATION(, -fstrict-aliasing, -fstrict-aliasing -s). Default is 'yes'.
The --enable-arch option can be used to enable optimization for specific architectures. If the option is set to 'yes' (the default if it is optimized for speed or size), -march=$(uname -m) is used. The architecture can be set explicitly by using --enable-arch=i686.
Adds the --enable-profile option which controls whether to emit profiling info. Default is 'no'. Other valid arguments are 'flat' for flat a profile, 'lcov' for line coverage, and 'both' for both.
Put this macro at the end of your if you use UDS m4 macros which affect compiler options. It sets CFLAGS and CXXFLAGS unless one of those variables is neither empty nor "-g -O2".
Checks for the presence / absolute path of a program. The full program path is stored in config.h. The macro takes four arguments:
  • the program name
  • --with-[x] option name
  • brief program description
  • config.h macro name
Described above. Adds the following options:
  • --enable-core-dumps
  • --enable-leak-check
  • --enable-zombies
  • --enable-log-allocs
  • --enable-rename-cores
  • --enable-std-backtraces
Likewise. All options default to 'no' and UDS_CHECK_DEBUG is not a prerequisite macro.
Adds the option --with-default-user to the configure script. The macro takes the default user name as first argument. The result is stored as DEFAULT_USER in config.h, and made available to Makefiles as the variable uds_defuser. This macro is intended for daemon / server programs. If --without-default-user is given, the value is set to an empty string.
Adds the option --with-default-group to the configure script. The macro takes the default group name as first argument. The result is stored as DEFAULT_GROUP in config.h, and made available to Makefiles as the variable uds_defgroup. This macro is intended for daemon / server programs. If --without-default-group is given, the value is set to an empty string.
Adds the --with-var-run-dir option to configure. The default is {localstatedir}/var/run/$1 where $1 is the optional argument to UDS_CHECK_VARRUNDIR. The result is stored in config.h as VARRUNDIR. A trailing slash is removed.
Note that if --with-var-run-dir is actually used, the argument to UDS_CHECK_VARRUNDIR is ignored.