可变参数宏

来源:互联网 发布:php windows相对路径 编辑:程序博客网 时间:2024/04/26 09:04

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

 
以下内容为程序代码:

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

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

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

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