diff options
Diffstat (limited to 'src/components/include/utils/macro.h')
-rw-r--r-- | src/components/include/utils/macro.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/components/include/utils/macro.h b/src/components/include/utils/macro.h index bf34b199b5..dc737dbe71 100644 --- a/src/components/include/utils/macro.h +++ b/src/components/include/utils/macro.h @@ -32,8 +32,12 @@ #ifndef SRC_COMPONENTS_INCLUDE_UTILS_MACRO_H_ #define SRC_COMPONENTS_INCLUDE_UTILS_MACRO_H_ +#ifdef DEBUG #include <assert.h> +#else // RELEASE #include <stdio.h> +#endif +#include "logger.h" @@ -54,14 +58,27 @@ #define FRIEND_DELETER_DESTRUCTOR(TypeName) \ friend utils::deleters::Deleter<TypeName>::~Deleter() +#ifdef DEBUG + #define ASSERT(condition) \ + do { \ + DEINIT_LOGGER(); \ + assert(condition); \ + } while (false) +#else // RELEASE + #define ASSERT(condition) \ + fprintf(stderr, "Failed condition \"" #condition "\" [%s:%d][%s]\n\n", \ + __FILE__, __LINE__, __FUNCTION__) +#endif + #define DCHECK(condition) \ if (!(condition)) { \ - printf("\nDCHECK [%s:%d][%s]", __FILE__, __LINE__, __FUNCTION__); \ - printf("[Check failed: " #condition "]\n\n"); \ - assert(false); \ + CREATE_LOGGERPTR_LOCAL(logger_, "assert"); \ + LOG4CXX_FATAL(logger_, "DCHECK failed with \"" << #condition \ + << "\" [" << __FUNCTION__ << "][" << __FILE__ << ':' << __LINE__ << ']'); \ + ASSERT((condition)); \ } -#define NOTREACHED() DCHECK(false) +#define NOTREACHED() DCHECK(!"Unreachable code") // Allows to perform static check that virtual function from base class is // actually being overriden if compiler support is available |