gcc -E -dM - </dev/null | grep "STDC_VERSION"
或者
printf("%ld\n",__STDC_VERSION__);
printf("%ld\n",__cplusplus);
對應關系如下
如果沒查到,則默認是c89的標准;
如果是#define __STDC_VERSION__ 199901L,則默認支持的是c99標准;
如果是#define __STDC_VERSION__ 201112L,則默認支持的c11標准;
- C ++ 98:
__cplusplus
是199711L
- C ++ 11:
__cplusplus
是201103L
- C ++ 14:
__cplusplus
是201402L
- C ++ 17:
__cplusplus
是201703L