我在论坛中搜索了很多关于我必须在代码中使用 _Generic 主表达式的问题。我编写了一个宏来使用 _Generic 功能获取变量的数据类型:
#define CHECK_DATA_TYPE(x) _Generic((x), /* Get the name of a type */ \
bool: DATA_TYPE_BOOL, \
u8 : DATA_TYPE_U8, \
s8 : DATA_TYPE_S8, \
u8 : DATA_TYPE_U16, \
s8 : DATA_TYPE_S16, \
u8 : DATA_TYPE_U32, \
s8 : DATA_TYPE_S32)
到目前为止,在代码中,我调用了宏:
u8 test = 10; u8 val = CHECK_DATA_TYPE(test);
所以,我有一个编译错误,表明 _Generic 函数没有定义:
W1020B:警告:标识符“_Generic”未定义 E4254B:不允许类型名称 E4018B:应为“)” E4065B:应为“;”
有任何想法吗?重要的是表明我使用 Softune C 编译器编译了我的项目。