The macro definition uses variable parameters, which makes it much easier to use. For details, refer to the msdn example:
Support for variadic macros was introduced in Visual C ++ 2005.
// Variadic_macros.cpp
# Include <stdio. h>
# Define EMPTY
# Define CHECK1 (x,...) if (! (X) {printf (_ VA_ARGS __);}
# Define CHECK2 (x,...) if (x) {printf (_ VA_ARGS __);}
# Define CHECK3 (...) {printf (_ VA_ARGS __);}
# Define MACRO (s,...) printf (s, _ VA_ARGS __)
Int main (){
CHECK1 (0, "here % s", "are", "some", "varargs1 (1) \ n ");
CHECK1 (1, "here % s", "are", "some", "varargs1 (2) \ n"); // won't print
CHECK2 (0, "here % s", "are", "some", "varargs2 (3) \ n"); // won't print
CHECK2 (1, "here % s", "are", "some", "varargs2 (4) \ n ");
// Always invokes printf in the macro
CHECK3 ("here % s", "are", "some", "varargs3 (5) \ n ");
MACRO ("hello, world \ n ");
// MACRO ("error \ n", EMPTY); wocould cause C2059
}
Here are some varargs1 (1)
Here are some varargs2 (4)
Here are some varargs3 (5)
Hello, world