You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by Ondrej Pacovsky <op...@jikos.cz> on 2006/04/11 11:13:56 UTC
dangerous assert macro
Hi, I'd just like to note that the LOG4CXX_ASSERT macro might be a bit
dangerous because of its usage of the "condition" param:
#define LOG4CXX_ASSERT(logger, condition, message) { \
if (!condition && logger->isErrorEnabled()) {\
logger->forcedLog(::log4cxx::Level::getError(), message,
LOG4CXX_LOCATION); }}
when used e.g. as LOG4CXX_ASSERT(lmain, false || true, "damn"), it
producess the error message when it shouldn't.
FIX: use parentheses
#define LOG4CXX_ASSERT(logger, condition, message) { \
if (!(condition) && logger->isErrorEnabled()) {\
logger->forcedLog(::log4cxx::Level::getError(), message,
LOG4CXX_LOCATION); }}
cheers,
Ondrej