Was a C90, C99, or C11 compiler used?

Derek Jones from The Shape of Code

How can a program figure out whether it has been compiled with a C90, C99 or C11 compiler?

Support for the // style of commenting was added in C99.

Support for Unicode string literals (e.g., U"Hello World") was added in C11.

Putting these together we get the following:


#define M(U) sizeof(U"s"[0])

int main(void)
    switch(M("")*2 //**/ 2
       case 1: printf("C90\n"); break;
       case 2: printf("C99\n"); break;
       case 8: printf("C11\n"); break;