I am trying to create a macro that executes blocks of code only if it's a debug build. I've managed to make one that executes one line only if debug is enabled, but i cannot figure out how to do a whole block of code.
the one line macro is below:
#include <iostream>
//error checking
#if defined(DEBUG) | defined(_DEBUG)
#ifndef DBG_ONLY
#define DBG_ONLY(x) (x)
#endif
#else
#ifndef DBG_ONLY
#define DBG_ONLY(x)
#endif
#endif
int main () {
DBG_ONLY(std::cout << "yar" << std::endl);
return 0;
}