Menu

Determine the version of the C standard used by the compiler (MinGW, GCC, and etc.)

1 |  #include <stdio.h>
2 |  void main()
3 |  {
4 |  #if __STDC_VERSION__ > 202000L
5 |  printf("Looks like your C compiler is from the future. :)\n");
6 |  #endif
7 |  #if __STDC_VERSION__ == 202000L
8 |  printf("__STDC_VERSION__ = %ldL = C2x\n", __STDC_VERSION__);
9 |  #endif
10|  #if __STDC_VERSION__ == 201710L
11|  printf("__STDC_VERSION__ = %ldL = C18\n", __STDC_VERSION__);
12|  #endif
13|  #if __STDC_VERSION__ == 201112L
14|  printf("__STDC_VERSION__ = %ldL = C11\n", __STDC_VERSION__);
15|  #endif
16|  #if __STDC_VERSION__ == 199901L
17|  printf("__STDC_VERSION__ = %ldL = C99\n", __STDC_VERSION__);
18|  #endif
19|  #if __STDC_VERSION__ == 199409L
20|  printf("__STDC_VERSION__ = %ldL = C95\n", __STDC_VERSION__);
21|  #endif
22|  #if __STDC_VERSION__ < 199409L
23|  printf("C compiler uses \"ANSI C\" (C89) or C90 standart. \n");
24|  #endif
25|  }

Download C/C++ Samples

Posted by Nerijus 2021-01-16 Labels: C

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.