#include #include #include #include // Check whether _Generic can uniquely identify pointers to base primitive types #define INSTANCE(X) X* : #X #define POLY_WHICH(ARG) (_Generic(ARG \ , INSTANCE(_Bool) \ , INSTANCE(char) \ , INSTANCE(signed char) \ , INSTANCE(unsigned char) \ , INSTANCE(short) \ , INSTANCE(unsigned short) \ , INSTANCE(int) \ , INSTANCE(unsigned int) \ , INSTANCE(long) \ , INSTANCE(unsigned long) \ , INSTANCE(long long) \ , INSTANCE(unsigned long long) \ , default: "default")) static bool check(const char *expected,const char *got) { if (strcmp(expected,got)) { printf("%s detected as %s\n",expected,got); return false; } return true; } #define TYPE(TYP) { TYP *x=NULL; assert(check(#TYP,POLY_WHICH(x))); } int main(int argc,char **argv) { TYPE(_Bool) TYPE(char) TYPE(signed char) TYPE(unsigned char) TYPE(short) TYPE(unsigned short) TYPE(int) TYPE(unsigned int) TYPE(long) TYPE(unsigned long) TYPE(long long) TYPE(unsigned long long) return 0; }