I have a bit of code where I want to have logging only if DEBUG is defined. So I though I might be able to replace a Token (here: "DEBUGLOG") with the comment string "//". But how to do?
#ifndef DEBUG
#define DEBUGLOG //
#endif
[...]
DEBUGLOG printf("Debug String"\n);
[...]
There is no definition of DEBUG somwhere else in the code. But my gcc compiles this line and the program itself executes the printf();
Why?
I tried to include it in parantheses like this, but it gets an compile error:
#ifndef DEBUG
#define DEBUGLOG "//"
#endif
This is the compiler message:
beispiel.c:45:10: error: expected ‘;’ before ‘printf’
DEBUGLOG printf("Debug String"\n);
^
Any hints?