What's the simplest way to ensure that only one of two names is defined, for example:
#define USE_OPTION1
#define USE_OPTION2
#if not(USE_OPTION1 ^ USE_OPTION2)
#error "You must use at least one option, but not both"
#endif
I know there's no logical XOR in C or C++, so what's the best way of doing this? It doesn't have to be this, does it:
#define USE_OPTION1
#define USE_OPTION2
#ifdef USE_OPTION1
#ifdef USE_OPTION2
#error "You can't use both"
#endif
#endif
#ifdef USE_OPTION2
#ifdef USE_OPTION1
#error "You can't use both"
#endif
#endif
#ifndef USE_OPTION1
#ifndef USE_OPTION2
#error "You must use at least one"
#endif
#endif