From e3743b5f303467c9a303f9b8cf386b8c73d35605 Mon Sep 17 00:00:00 2001 From: Davis King Date: Tue, 25 Dec 2012 09:59:07 -0500 Subject: [PATCH] Added a config.h file that can be used to permanently enable or disable asserts when creating a shared library for dlib. --- dlib/assert.h | 13 ++++++++----- dlib/config.h | 12 ++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 dlib/config.h diff --git a/dlib/assert.h b/dlib/assert.h index c62049d7f..41ff458b6 100644 --- a/dlib/assert.h +++ b/dlib/assert.h @@ -3,7 +3,7 @@ #ifndef DLIB_ASSERt_ #define DLIB_ASSERt_ - +#include "config.h" #include #include #include "error.h" @@ -49,11 +49,14 @@ namespace dlib // ----------------------------- -#if defined DEBUG || defined _DEBUG +#if defined DLIB_DISABLE_ASSERTS + // if DLIB_DISABLE_ASSERTS is on then never enable DLIB_ASSERT no matter what. + #undef ENABLE_ASSERTS +#endif + +#if !defined(DLIB_DISABLE_ASSERTS) && ( defined DEBUG || defined _DEBUG) // make sure ENABLE_ASSERTS is defined if we are indeed using them. - #ifndef ENABLE_ASSERTS - #define ENABLE_ASSERTS - #endif + #define ENABLE_ASSERTS #endif // ----------------------------- diff --git a/dlib/config.h b/dlib/config.h new file mode 100644 index 000000000..97f06ac3a --- /dev/null +++ b/dlib/config.h @@ -0,0 +1,12 @@ + + +// If you are compiling dlib as a shared library and installing it somewhere on your system +// then it is important that any programs that use dlib agree on the state of the +// DLIB_ASSERT statements (i.e. they are either always on or always off). Therefore, +// uncomment one of the following lines to force all DLIB_ASSERTs to either always on or +// always off. If you don't define one of these two macros then DLIB_ASSERT will toggle +// automatically depending on the state of certain other macros, which is not what you want +// when creating a shared library. +//#define ENABLE_ASSERTS // asserts always enabled +//#define DLIB_DISABLE_ASSERTS // asserts always disabled +