Why doesn't my simple C macro work?
问题 I want to make a simple macro that calls printf() twice like this #ifdef ENABLE_DEBUGPRINTF #define DEBUGPRINTF(msg) printf("At sim_time = %f:", sim_time); printf(msg); #else #define DEBUGPRINTF(msg) //evalutes to nothing #endif Now when I call DEBUGPRINTF("Processed event type: %d with value %f\n", id, data) It prints the first part "At sime_time = ... " correctly but the latter part where it says "Processed events ... " prints the value for id and data incorrectly. Meanwhile printf(