0
我中定義的宏來DbgPrint到打印消息時_DEBUG定義DbgPrint輸出的不同形成的宏輸出到DbgPrint
#define MYDBGPRINT(X) #ifdef _DEBUG \
DbgPrint(X) \
#endif
但輸出是從DbgPrint不同例如
ULONG id=0;
MYDBGPRINT("the value of the id : %u ",id) //outputs garbage
DbgPrint("the value of the id : %u ",id) //outputs the correct value of id
注意,__VA_ARGS__方法可能是編譯器特定的。我已經使用它與GCC,但我不確定它是否與微軟的編譯器一起工作。 – jduck
第二種解決方案是可以的。我必須使用可變宏http://en.wikipedia.org/wiki/Variadic_macro – zaki