You have two options:
Use numbers instead of strings, and give them names using macros:
#define HELLO 1#define ASDASD 2#define MY_MACRO HELLO#if MY_MACRO == HELLO// ...#endif
Don't use preprocessor, use a plain
if
(orif constexpr
, the only difference here is that the latter forces the condition to be a compile-time constant). This means that all branches have to be valid (have to compile) regardless of which one is choosen:#define MY_MACRO "hello"int main(){ if constexpr (MY_MACRO == std::string_view("hello")) { }}
Or make
MY_MACRO
a globalconstexpr std::string_view
variable if you don't need to override it with compiler flags.