如何检查是否在单个#ifdef中定义了多个宏中的一个? [英] How do I check if one of multiple macros is defined in a single #ifdef?

查看:1598
本文介绍了如何检查是否在单个#ifdef中定义了多个宏中的一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些C ++代码,如果定义 __ APPLE __ __ linux 宏,则需要执行操作。

I have some C++ code, and want to perform an action if the __APPLE__ or __linux macros are defined.

如果我将它作为一个普通的如果有条件,那将很容易使用 | |

If I did it as a normal if conditional, it would be easy using ||:

if (something || something) { .. code .. }

但是据我所知,没有 || #ifdef 语句的运算符。我如何检查 __ APPLE __ __ linux 是使用单个 #ifdef 语句

But as of what I know there is no || operator for #ifdef statements. How would I check if __APPLE__ or __linux is defined using a single #ifdef statement?

推荐答案

您不能在单个 #ifdef 会单个 #if 吗?

You can't in a single #ifdef would a single #if do instead?

#if defined(__APPLE__) || defined(__linux)

这也适用于

#if defined __APPLE__ || defined __linux

这篇关于如何检查是否在单个#ifdef中定义了多个宏中的一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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