To use some of the features UDS provides, you have to configure the library
in your program. This has 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
const uds::uds_flags_t uds::flags = uds::leak_check | uds::summon_zombies;
The available flags are:
enableval=$debug
AC_MSG_CHECKING(whether to force core dumps on fatal errors)
AC_ARG_ENABLE(core-dumps,[ --enable-core-dumps dump the core on fatal errors])
if test "$enableval" != "no"; then
AC_MSG_RESULT(yes)
AC_DEFINE(FORCE_CORE_DUMPS,,[force core dumps on fatal errors])
else
AC_MSG_RESULT(no)
fi
enableval=$debug
AC_MSG_CHECKING(whether to check for memory leaks)
AC_ARG_ENABLE(leak-check,[ --enable-leak-check check for memory leaks])
if test "$enableval" != "no"; then
AC_MSG_RESULT(yes)
AC_DEFINE(LEAK_CHECK,,[check for memory leaks])
else
AC_MSG_RESULT(no)
fi
enableval=$debug
AC_MSG_CHECKING(whether to create zombie objects)
AC_ARG_ENABLE(zombies,[ --enable-zombies create zombie objects])
if test "$enableval" != "no"; then
AC_MSG_RESULT(yes)
AC_DEFINE(SUMMON_ZOMBIES,,[create zombie objects])
else
AC_MSG_RESULT(no)
fi
enableval=no
AC_MSG_CHECKING(whether to log memory allocations)
AC_ARG_ENABLE(log-allocs,[ --enable-log-allocs log memory allocations])
if test "$enableval" != "no"; then
AC_MSG_RESULT(yes)
AC_DEFINE(LOG_ALLOCS,,[log memory allocations])
else
AC_MSG_RESULT(no)
fi
enableval=$debug
AC_MSG_CHECKING(whether to rename uds coredumps)
AC_ARG_ENABLE(rename-cores,[ --enable-rename-cores rename uds coredumps])
if test "$enableval" != "no"; then
AC_MSG_RESULT(yes)
AC_DEFINE(RENAME_UDS_CORES,,[rename uds coredumps])
else
AC_MSG_RESULT(no)
fi
In this code, it is assumed that the variable 'debug' is 'yes' when debugging is
enabled, and 'no' when it is disabled. It depends on the value of 'debug' whether
some features are enabled by default.#ifdef LOG_ALLOCS
line in udsdeff.cc out. This way you have to rebuild only one object file.