C中"非活动"预处理程序块的含义是什么?

Muh*_*med 3 c visual-studio-2010 c-preprocessor

我找到了一些代码行,这些代码在C的源代码预处理器块中变暗.我的编译器,MS Visual Studio,将其命名为"非活动预处理程序块".这意味着什么,我的编译不会考虑这些代码行,以及如何使它成为活动块?

Sin*_*all 6

非活动预处理程序块是由于预处理程序指令而停用的代码块.最简单的例子是:

#if 0
//everytyhing here is inactive and will be ignored during compilation
#endif
Run Code Online (Sandbox Code Playgroud)

一个更常见的例子是

#ifdef SOME_VAR
// code
#else
// other code
#endif
Run Code Online (Sandbox Code Playgroud)

在这种情况下,根据是否SOME_VAR定义,第一或第二代码块将是无效的.