It is #endif not #end
A small addition to Elysia's idea:
Code:
#ifdef DEBUG
#define my_printf printf
#else
#define my_printf ;//
#end
Since you might have
Code:
if (something)
my_printf(...);
Of course what Mordor actually did would be the best for C99.
testing cpjust idea
Code:
#include <stdlib.h>
#include <stdio.h>
#define DEBUG
#ifdef DEBUG
#define my_printf(x) printf(x)
#else
#define my_printf
#endif
int main()
{
printf(("%s", "10"));
}
this works. This doesn't compile
Code:
#include <stdlib.h>
#include <stdio.h>
#define DEBUG
#ifdef DEBUG
#define my_printf(x) printf(x)
#else
#define my_printf
#endif
int main()
{
printf(("%d", 10));
}
Both give a warning (in GCC). That the left hand operant on the comma has no effect. The error the later gets is that
"passing arg 1 of 'printf' makes pointer from integer without a cast"
What I think happens is that this
Code:
("%s", "hey") --> ("%s" "hey") --> ("%shey")
so the first one will run. The second I have no idea. Or something equally weird happens.
Conclusion: be careful when being tricky with macros
What maybe you could do is change it to
Code:
#define my_printf(x, y) printf(x, y)
and always use printf with two inputs and combine multiple of them for more inputs