如何检查单个#ifdef中是否定义了多个宏之一?

bea*_*akr 15 c++ conditional-compilation c-preprocessor

我有一些C++代码,并且如果定义了__APPLE____linux宏,则想要执行操作.

如果我把它作为一个正常的if条件,它将很容易使用||:

if (something || something) { .. code .. }
Run Code Online (Sandbox Code Playgroud)

但据我所知,没有||运营商的#ifdef陈述.我将如何检查__APPLE____linux使用一个单一的定义#ifdef语句?

joh*_*ohn 28

相反,你不能#ifdef单一#if做一次吗?

#if defined(__APPLE__) || defined(__linux)
Run Code Online (Sandbox Code Playgroud)

如果您愿意,这也有效

#if defined __APPLE__ || defined __linux
Run Code Online (Sandbox Code Playgroud)