I want to compile a project differently, according to a constant defined by #define, like this:
#define USE_COMPONENT_X #if USE_COMPONENT_X ... #endif
Hopefully I'm not way off topic, but rather than a "constant" perhaps define an interface for the constant's type and then use one of the many dependency injection frameworks to manage the definition, injection and lifetime of your "constant".