可能重複:
C/C++: How to make a variadic macro (variable number of arguments)宏與論據
只是想知道,如果這是在所有可能的,所以不是即時通訊目前是如何處理的日誌記錄和消息有多個參數,即時通訊有對於每種情況具有許多不同的宏,例如:
#define MSG( msg )
#define MSG1( fmt, arg1 )
#define MSG2( fmt, arg1, arg2 )
#define MSG3( fmt, arg1, arg2, arg3 )
#define MSG4( fmt, arg1, arg2, arg3, arg4 )
#define MSG5( fmt, arg1, arg2, arg3, arg4, arg5 )
#define MSG6( fmt, arg1, arg2, arg3, arg4, arg5, arg6)
是否有任何方法來定義一個宏在接受任何數量的參數?
感謝
沒有*標準*的方式。但是,最常用的編譯器支持可變宏。不過,我會讓其他人發佈這個答案。 :) – GManNickG 2010-01-08 09:45:23
@GMan我會讓問題的鬼過去的回答:http://stackoverflow.com/questions/679979/cc-how-to-make-a-variadic-macro-variable-number-of-arguments – 2010-01-08 09:47:35
@G男人更好的答案比什麼都沒有,但? – 2010-01-08 09:52:36