用预定义宏判断C标准的版本

预定义宏__STC__和__STDC_VERSION__的配合使用,可以让我们编写兼容各种C标准的代码。

如下是一个典型的模板:

#ifdef __STDC__
        /* Some version of Standard C */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
        /* C99 */
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199409L
        /* C89 and Amendent 1 */
#else
        /* C89 but not Amendent 1 */
#endif
#else
        /* Not Standard C */
#endif