home ‣ variadic macros in msvc
| 04 Apr 2008 · Tags: programming, c++, msvc | ← newer • 64 of 588 • older → |
> Is there any way to support variadic macros in Visual Studio
> like gcc supports? If not, how do people write stuff like
> custom asserts that take variable parameters?
>
> http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
>
Depending on what you're after, you might find that the __noop
intrinsic will help you out.
#ifdef _DEBUG
void _MyDebugPrintf(const char* fmt, ...);
#define DPF _MyDebugPrintf
#else
#define DPF __noop
#endif
// later, ...
DPF("%s %s this works", FuncA(), FuncB());
FuncA and FuncB (or parameters in general) are not evaluated
in non _DEBUG builds. The compiler ignores the statement.
This is obviously not variadic macros, but you can do quite a
bit with it.
blog comments powered by Disqus