Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在#ifdef 语句中定义定义变量?
#ifdef VALUE #define VARIABLE 1 #else #define VARIABLE 1 #endif
是的,每行只有一个指令:
是的,但不是这样:
#ifdef VALUE int VARIABLE = 1; #else int VARIABLE = 2; #endif
这些是变量定义。您正在做的是定义一些预处理器指令。在你的情况下你不能这样做VARIABLE = 3,但你可以在这里。
VARIABLE = 3