The best way is to show it with code. I'm compiling this as a Win32 C++ project under Visual Studio 2017:
#include <strsafe.h>
#include <stdio.h>
//Trace outout
#ifdef _DEBUG
#define TRACE(s) ::OutputDebugString(s)
#define TRACE(s, ...) \
{ WCHAR __dbg_buff[1024]; if(SUCCEEDED(::StringCchPrintf(__dbg_buff, _countof(__dbg_buff), s, __VA_ARGS__))) { ::OutputDebugString(__dbg_buff);} else ASSERT(NULL);}
#else
#define TRACE(s) ((void)0)
#define TRACE(s, ...) ((void)0)
#endif
The idea is to use the macro in these two types of cases:
TRACE(L"value=%02X", v);
TRACE(L"\n");
But my macro definition produces this error:
warning C4005: 'TRACE': macro redefinition
note: see previous definition of 'TRACE'
error C2059: syntax error: ')'
What is the way to define it so that it takes both variadic and non-variadic form?