Wrap a preprocessor check in a explicit static constexpr inline bool (or implicit static constexpr bool which get converted to same type) and you get a clean, type-safe flag that the compiler can optimize away entirely — no #ifdef spaghetti scattered across codebases:
struct S // or class
{
static constexpr inline bool is_my_build =
#ifdef MY_BUILD
true;
#else
false;
#endif // #ifdef MY_BUILD
};
Now you can use if constexpr (is_my_build) or regular if (is_my_build) anywhere inside the class / struct — the dead branch gets eliminated at compile time either way. One #ifdef, one place, zero overhead.