里面的#define #IFDEF [英] #ifdef inside #define

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

问题描述

我想写的东西是这样的:

I am trying to write something like this:

#define COV_ON(x) \
                #ifdef COVERAGE_TOOL \
                    _Pragma (COVERAGE #x)
                #endif

有什么办法来定义 COV_ON 这样吗?我知道我在上面所做的是错的,因为我不能有 #IFDEF 里面的#define。 (不是的#define 允许的字符)。
那么,有没有解决方案?

Is there any way to define COV_ON like this? I know what I have done above is wrong as I can't have #ifdef inside #define. (# is not an allowed character in #define). So is there any solution?

推荐答案

不可能的。做到这一点的其他方式:

Not possible. Do it the other way around:

#ifdef COVERAGE_TOOL
#define COV_ON(x) _Pragma (COVERAGE #x)
#else
#define COV_ON(x)
#endif

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

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