开发者社区 问答 正文

如何使用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 2365 分享 版权
1 条回答
写回答
取消 提交回答
  • GCC 4.9 以上版本才支持 _Generic, 而我使用的是 GCC 4.8.2

    2019-07-17 19:30:41
    赞同 展开评论
问答地址: