Menu

C/C++ / Blog: Recent posts

Sveiki,

Sveiki, kompinis blogas, tikiuosi bent kazkam patiks,

Posted by Nerijus 2023-10-20

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