在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\
}\
})
答案 0 :(得分:5)
C11引入_Generic
关键字来完全按照您的要求进行操作。