Using logical operators with macros
c, conditional-compilation, macros
Solution
Besides `#ifdef`, the preprocessor supports the more general `#if` instruction; actually, `#ifdef MACRO` is a shortcut for `#if defined(MACRO)`, where `defined` is a "preprocessor function" that returns 1 if the macro is defined; so, you can do:
#if defined(MACRO1) || defined(MACRO2)
void foo()
{
}
#endif
Problem
I have a piece of code which I want to include if either of two macros are defined ``` #ifdef MACRO1 || MACRO2 void foo() { } #endif ``` How do I accomplish this in C?