is there a way to write macros with a variable argument list in visual C++?
问题 As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...) printf(fmt); Is there a way to do that in VC++? 回答1: Yes but only since VC++ 2005. The syntax for your example would be: #define DBGPRINT(fmt, ...) printf(fmt, __VA_ARGS__) A full reference is here. 回答2: Yes, you can do this in Visual Studio C++ in versions 2005 and beyond (not sure about VS 2003). Take a look at VA_ARGS . You can basically do something like this: #define DBGPRINTF(fmt, ...) printf(fmt, __VA_ARGS_