如何区分" long"," double"和" const char *"

时间:2016-01-19 10:51:02

标签: c

在64位Linux中,sizeof(long)sizeof(const char*)是相同的,我希望实现以下代码而无需特定的附加参数(我的意思是不要使用特定的类型参数)

#define squeeze(smth) ({\
if (sizeof(smth) == sizeof(long)) {\
// do smth\
} else if (sizeof(smth) == sizeof(const char *)) {\
// do other\
}\
})

1 个答案:

答案 0 :(得分:5)

C11引入_Generic关键字来完全按照您的要求进行操作。