I know I've seen something like this before, but it's been a while and I can't get it to work. Does this ring a bell for anyone...
The theory is that if you encase printf's arguments in parentheses, the macro will take them as a single argument, and everything works fine...except I'm forgetting something, and the compiler simplifiesCode:#include <stdio.h> #define DEBUG(t) fprintf(debug_out, t) int main(void) { FILE* debug_out = fopen("debug.txt", "w"); DEBUG("This is only a test...\n"); DEBUG(("1 = %i\n", 1)); DEBUG("This was only a test...\n"); fclose(debug_out); return 0; }
to justCode:("1 = %i\n", 1)
Any thoughts? Thanks in advance.Code:1