Added a config.h file that can be used to permanently enable or disable

asserts when creating a shared library for dlib.
This commit is contained in:
Davis King 2012-12-25 09:59:07 -05:00
parent 6efc800b54
commit e3743b5f30
2 changed files with 20 additions and 5 deletions

View File

@ -3,7 +3,7 @@
#ifndef DLIB_ASSERt_ #ifndef DLIB_ASSERt_
#define DLIB_ASSERt_ #define DLIB_ASSERt_
#include "config.h"
#include <sstream> #include <sstream>
#include <iosfwd> #include <iosfwd>
#include "error.h" #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. // make sure ENABLE_ASSERTS is defined if we are indeed using them.
#ifndef ENABLE_ASSERTS #define ENABLE_ASSERTS
#define ENABLE_ASSERTS
#endif
#endif #endif
// ----------------------------- // -----------------------------

12
dlib/config.h Normal file
View File

@ -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