Skip to content

๐ŸŒ€ Compiler C Standard Detection

Feldwor edited this page Oct 30, 2021 · 5 revisions

Preprocessor Conditional Macros

// Comments on your silly C compiler

// #if __STDC_VERSION__ == 201112L
//   #error C11 compiler is too old, use newer standard Compiler
// 
// #endif

#if __STDC_VERSION__ == 199901L
  #error You are using C99 compiler that is considered too old. Switch to C11 Standard or Newer. (std=C11) 
#endif

#if __STDC_VERSION__ < 199901L	
  #error Sucky compiler, use C11 Standard Compiler or newer.
#endif

Printing version of the C standard in use.

#include <stdio.h>
int main(){
   printf("C Standard Version: %i\n" ,__STDC_VERSION__);

}
C:\Users\user\Desktop>tcc -run test.c
C Standard Version: 199901
C:\Users\user\Desktop>tcc -std=c99 -run test.c
C Standard Version: 201112
C:\Users\user\Desktop>tcc -std=c11 -run test.c
C Standard Version: 201112