I\'d like to make a debug logging function with the same parameters as printf. But one that can be removed by the pre-processor during optimized builds.
printf
Having come across the problem today, my solution is the following macro:
static TCHAR __DEBUG_BUF[1024]; #define DLog(fmt, ...) swprintf(__DEBUG_BUF, fmt, ##__VA_ARGS__); OutputDebugString(__DEBUG_BUF)
You can then call the function like this:
int value = 42; DLog(L"The answer is: %d\n", value);