Using C++, I need a macro that will replace a function to do nothing if it is running in release mode. So, in debug mode the function will be executed, but in release mode it will not.
Something like this:
static void foo(int,int)
#ifdef NDEBUG
#define foo(x,y)
#endif
…and the function body is defined in a separate .cpp file and is part of a class, which is why I think this isn’t working?
actual code..
header
static void ValidateInput(const SeriesID *CurrentSeries, const AEnum_TT_TICK_ROUND& roundType = TT_TICK_ROUND_NONE);
.cpp
void TTBaseTick::ValidateInput(const SeriesID *CurrentSeries, const AEnum_TT_TICK_ROUND& roundType)
{
#ifndef _DEBUG
if (!CurrentSeries)
{
throw TTTick::Ex(TTTick::SeriesNull);
}
else if (CurrentSeries->precision <= 0)
{
throw TTTick::Ex(TTTick::PrecisionInvalid);
}
else if(!roundType.IsValidValue(roundType))
{
throw TTTick::Ex(TTTick::InvalidParam);
}
#endif
}
1 Answer