-3

I want to use or in a preprocessor #ifdef directive. I've tried using the || operator but it hasn't worked. How can I do this?

0

2 Answers 2

4
#if defined(SOMETHIG1) || defined(SOMETHING2)
/* .... */
#endif
1

You can't.

#ifdef COND is short for #if defined(COND). It has no way to combine conditions.

But, you don't need to use #ifdef! If you write it out in full, you can make use of all the operators you need:

#if defined(COND1) || defined(COND2)

Not the answer you're looking for? Browse other questions tagged or ask your own question.