我试图定义一个通用的函数使用C中_Generic采取输入,这是我写的如何定义通用函数以使用_Generic在C中输入?
#include <stdio.h>
#define readlong(x) scanf("%lld",&x);
#define read(x) scanf("%lld",&x);
#define scan(x) _Generic((x), \
long long: readlong, \
default: read \
)(x)
但是当我编译它的gcc 5.3.0使用gcc test.c -std=C11
,我得到错误:
error: 'readlong' undeclared (first use in this function)
请问[此问题](http://stackoverflow.com/questions/9804371/syntax-and-sample-usage-of-generic-in-c11)有帮助吗? –
@MichaelWalz我已经读过那篇了。 – Yogendra
在'#define'行之后删除';'。 –