Is there a way to do something like:
#ifdef A || B
... some code ...
#endif
#include <stdio.h>
/* make sure these macros haven't been defined behind our back */
#if defined(COND_A)
#undef COND_A
#endif
#if defined(COND_B)
#undef COND_B
#endif
int main(void)
{
printf("COND_A and COND_B are undefined ... ");
#if defined(COND_A) || defined(COND_B)
printf(" wrong.\n");
#else
printf(" right.\n");
#endif
#define COND_A
printf("COND_A is defined, and COND_B is not... ");
#if !defined(COND_A) || defined(COND_B)
printf("wrong.\n");
#else
printf("right.\n");
#endif
#undef COND_A
#define COND_B
printf("COND_A is not defined, and COND_B is ... ");
#if defined(COND_A) || !defined(COND_B)
printf(" wrong.\n");
#else
printf(" right.\n");
#endif
#define COND_A
printf("COND_A and COND_B are both defined ... ");
#if !defined(COND_A) || !defined(COND_B)
printf("wrong.\n\n");
#else
printf("right.\n\n");
#endif
printf("The last test using the form !(x && y) "
"instead of !x || !y:\n"
"COND_A and COND_B are both defined ... ");
#if !(defined(COND_A) && defined(COND_B))
printf(" wrong.\n");
#else
printf(" right.\n ");
#endif
return 0;
}
[output]
COND_A and COND_B are undefined ... right.
COND_A is defined, and COND_B is not... right.
COND_A is not defined, and COND_B is ... right.
COND_A and COND_B are both defined ... right.
The last test using the form !(x && y) instead of !x || !y:
COND_A and COND_B are both defined ... right.