是否有一个C99的#define? [英] Is there a #define for C99?

查看:129
本文介绍了是否有一个C99的#define?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的事情在C99单向的东西,否则执行另一种方式。什么是的#define 来检查?

  #IFDEF C99
...
#其他
...
#万一


解决方案

有没有一个具体的的#define 值。只是检查 __ __ STDC_VERSION 和自己定义! ; - )

 #如果__STDC_VERSION__> = 199901L
/ C99 * code * /
C99的#define
#其他
/ *未C99 code * /
#万一
#IFDEF C99
/ *我的code在C99格式* /
#其他
/ *我的code在C99格式* /
#万一

编辑::一种更普遍的片断,从这里。我只是改变了定义的名称,以防万一,你会使用他们在code很多:

 #如果定义(__ STDC__)
#C89定义
如果定义#(__ STDC_VERSION__)
#C90定义
#如果(__STDC_VERSION__> = 199409L)
#C94定义
# 万一
#如果(__STDC_VERSION__> = 199901L)
#C99定义
# 万一
# 万一
#万一

I want to do something in C99 one way, otherwise to perform it another way. What is the #define to check for?

#ifdef C99
...
#else
...
#endif

解决方案

There is not an specific #define value. Just check __STDC_VERSION__ and define it yourself! ;-)

#if __STDC_VERSION__ >= 199901L
/* C99 code */
#define C99
#else
/* Not C99 code */
#endif


#ifdef C99
/*My code in C99 format*/
#else
/*My code in C99 format*/
#endif

EDIT: A more general snippet, from here. I've just changed the defined names, just in case you'll use them a lot on the code:

#if defined(__STDC__)
# define C89
# if defined(__STDC_VERSION__)
#  define C90
#  if (__STDC_VERSION__ >= 199409L)
#   define C94
#  endif
#  if (__STDC_VERSION__ >= 199901L)
#   define C99
#  endif
# endif
#endif

这篇关于是否有一个C99的#define?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆