开发者社区> 问答> 正文

如何使用C的_Generic

#define test(x) _Generic(x, int:test_i)(x)

void test_i(int x) {}

int main()
{ 
    int a = 1;
    test(a);
    return 0;
}

出现了编译错误:
warning: implicit declaration of function ‘_Generic’ [-Wimplicit-function-declaration]
error: expected expression before ‘int’

这是怎么回事?

展开
收起
a123456678 2016-06-07 18:27:53 2140 0
1 条回答
写回答
取消 提交回答
  • GCC 4.9 以上版本才支持 _Generic, 而我使用的是 GCC 4.8.2

    2019-07-17 19:30:41
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载