可变参数宏

来源:互联网 发布:淘宝订单贷款条件 编辑:程序博客网 时间:2024/04/25 15:38

新的C99规范支持了可变参数的宏,具体使用如下:


以下内容为程序代码:

 #include <stdarg.h>
 #include <stdio.h>

 #define LOGSTRINGS(fm, ...) printf(fm,__VA_ARGS__)

 int main()
 {
      LOGSTRINGS("hello, %d ", 10);
      return 0;
 }
 

 但现在似乎只有gcc才支持。

原创粉丝点击