I followed the online tutorial and wanted to use #undef
to design my debug output function. I wrote a debugOut.h
file.
The content is as follows:
#include <stdio.h>
#define NOOP //(void(0))
#undef DEBUG_PRINT
#if DEBUG_OUT
#define DEBUG_PRINT printf
#else
#define DEBUG_PRINT(...) NOOP
#endif
#undef DEBUG_OUT
Then I wrote a main function to test whether my design is correct.
#include<iostream>
#include "Header/debug_out.h"
#define DEBUG_OUT
int main(){
DEBUG_PRINT("module1 debug...\n");
printf("hello,world");
}
But the output result is only hello, world
. Why I defined #define DEBUG_OUT
, why is DEBUG_PRINT
not replaced with printf
I wrote it based on an online tutorial. I want to write an output function for c++ based on this. But in the sentence #define DEBUG_PRINT(...) NOOP
, what does (...)
represent? Is there any way I can output what the macro definition is replaced with?