0
How may I Know if I'm using C11 standards or other one?
Hi, lately I´ve been searching for C standards and I found that there are some differences in every standard. So, I want to know how can I be sure if I´m using determited standard and how to change between them.
2 Antworten
0
well that's right. After searching a lot of it, I think it depends on the compiler used.
I've downloaded Code Blocks 17.2 with mingw and I found this code to know which standard I'am using:
#include <stdio.h>
int main(void) {
#ifdef __STDC_VERSION__
printf("Aparentemente compatible con __STDC_VERSION__\n");
# if __STDC_VERSION__ == 199901L
printf("Este código fue compilando con el estandar C99.\n");
# elif __STDC_VERSION__ == 201112L
printf("Este codigo fue compilado con el estandar C11.\n");
# else
printf("Este codigo fue compilado con el estandar C94.\n");
# endif /* == */
#endif /* __STDC_VERSION__ */
#ifdef __cplusplus
printf("Aparentemente compilado con un compilador de C++\n");
# if __cplusplus >= 201103L
printf("Este codigo fue compilado bajo un estandar mayor o igual a C++11.\n");
# else
printf("Este codigo fue compilado bajo un estandar menor a C++11.");
# endif /* >= */
#endif /* __cplusplus */
#ifdef __STDC__
printf("Aparentemente compatible con __STDC__ y los estandares C89 y C90 ...\n");
#endif /* __STDC__ */
}
In this IDE version It shows me :
Apparently compatible with __STDC_VERSION__
This code was compiled with C11 standard
Apparently compatible with __STDC__ and C89 and C90 standards
However, HAPPY TO HELP, I didn´t understand thay way I should put that flag on my code. Would you explain it better, please?
0
Wow, that is very useful, thanks!