You seem to have inadvertently posted the answer to your own question without realising it.
Allow me to describe a tangential feature in C that you probably don't know about. It is a most useful feature when you're debugging software; it allows you to assert
that a condition is true and that condition will be checked during runtime (when you're running a debug build, that is).
That feature is assert
. The neat thing about assert
(aside from the fact that it introduces internal documentation which might aid maintenance) is that when you compile your programs as release builds, they will vanish from your machine code.
Section 7.2 of the C standard documents that the assert()
macro expands to ((void)0)
, which you appear to have concluded would cause errors. Which errors? Both the TRACE
you have defined in your example and the TRACE
I would define to look like FUBAR
are perfectly valid in C.
#define TRACE(...)
#define FUBAR(...) ((void)0)
int main() {
int a = 10, b = 20;
int c = 30;
TRACE(a, b);
FUBAR(c);
}
To emphasize, the code above compiles and runs as you should expect it to! After all, FUBAR
is how assert
is required to be implemented. There is another alternative, which I was hinting towards in the comments, if for some reason the above code doesn't work:
#include <assert.h>
#define TRACE(A,...) assert(A || 1)
These two va_start
and va_end
errors you see are caused by something else that we can't see in this question. If I had to hazard a guess, I'd suggest that you've forgotten to #include <stdarg.h>
. Sorry, I can't help you more with these two errors until you post an MCVE. I would normally wait for such an MCVE, but it seems you were prompted for one over six months ago and have yet to respond... If you do, please ping me and I'll try to update my answer :)