__VA_ARGS__可变宏参数

#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__可变宏参数
分享URL:http://hxwzsj.com/article/pjedji.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 营销型网站建设 高端网站建设 成都网站建设 重庆企业网站建设 成都做网站建设公司 古蔺网站建设 网站制作 定制网站建设 高端网站设计 成都网站建设公司 成都响应式网站建设 LED网站设计方案 做网站设计 成都网站制作 成都网站设计 四川成都网站建设 成都响应式网站建设 成都网站建设公司 公司网站建设 成都网站制作 成都网站建设公司 网站设计