gcc

宏定义

  可变参数:__VA_ARGS__

 1 #include <stdio.h>
 2 
 3 #define print1(fmt, ...) \
 4     printf(fmt, ##__VA_ARGS__) //相当于直接替换...的内容
 5 
 6 #define print2(...) \
 7     printf(__VA_ARGS__)  //直接按默认规则帮你拼好字符串
 8 
 9 int main()
10 {
11     print1("%s\n", "hello");
12     print2("%s\n", "hello");
13 }
14 
15 输出:
16 hello
17 hello

 

posted on 2018-11-08 12:02  laymond  阅读(86)  评论(0)    收藏  举报

导航