[英]How do I check if one of multiple macros is defined in a single #ifdef?
I have some C++ code, and want to perform an action if the __APPLE__
or __linux
macros are defined. 我有一些C ++代码,并希望如果执行一个动作__APPLE__
或__linux
宏定义。
If I did it as a normal if
conditional, it would be easy using ||
如果我在正常if
下将其作为正常条件,那么使用||
会很容易 : :
if (something || something) { .. code .. }
But as of what I know there is no ||
但据我所知,没有||
operator for #ifdef
statements. #ifdef
语句的运算符。 How would I check if __APPLE__
or __linux
is defined using a single #ifdef
statement? 我将如何检查是否__APPLE__
或__linux
使用单一定义#ifdef
语句?
You can't in a single #ifdef
would a single #if
do instead? 你不能在一个#ifdef
单一的#if
代替吗?
#if defined(__APPLE__) || defined(__linux)
this also works if you prefer 如果您愿意,这也有效
#if defined __APPLE__ || defined __linux
In my C++ there is. 在我的C ++中有。
#if defined(__APPLE__) || defined(__linux)
// ...
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.