If-directive macro comparison
问题 Why is the #if condition in the following code fulfilled: #include <iostream> #define VALUE foo int main() { #if VALUE == bar std::cout << "WORKS!" << std::endl; #endif // VALUE } 回答1: The page on cppreference.com states: After all macro expansion and evaluation of defined and __has_include (since C++17) expressions, any identifier which is not a boolean literal is replaced with the number 0 (this includes identifiers that are lexically keywords, but not alternative tokens like and). So