#include
#include
#define DEBUG(...) printf(__VA_ARGS__)
#define ERROR(fmt,...) printf(fmt,__VA_ARGS__)
int main() {
int y = 999;
//宏展开: printf("Y = %d\n", y)
DEBUG("Y = %d\n", y);
//宏展开: printf("a = %d,b = %d,c = %d\n",1, 2, 3);
DEBUG("a = %d,b = %d,c = %d\n", 1, 2, 3);
//宏展开: printf("Y = %d\n", y)
ERROR("Y = %d\n", y);
//宏展开: printf("a = %d,b = %d,c = %d\n",1, 2, 3);
ERROR("a = %d,b = %d,c = %d\n", 1, 2, 3);
ERROR("haah");//宏展开: printf("haah", );; 为了去掉逗号,请使用 ## __VA_ARGS__
system("pause");
return 0;
}
分享题目:__VA_ARGS__可变宏参数
标题路径:
http://cdweb.net/article/pjedji.html