看似评估#if false 块内的预处理器代码
Seeming evaluation of preprocessor code inside a #if false block
我正在通过 MonoDevelop 4.0.1(Unity 的当前版本)使用 C#,
并且遇到了一个看似奇怪的语言。
这是我的整个 .cs 文件:
#if false
#define foo
#endif
class myClass {
int member;
}
#if false
#error this error does not trigger
#undef foo
// "cannot define or undefine preprocessor symbols after first token in file
#endif
我理解关于在声明令牌后不 #undef
预处理器符号的规则,但在这种情况下我 不 #undef
因为 #undef
在 #if false
.
中
此示例并非完全是人为设计的,它是尝试通过 here.
中描述的方法在 C# 和 C++ 中编译单个源文件
Visual Studio 不会抱怨相同的代码。我认为您发现了 Mono 中的一个错误。
我正在通过 MonoDevelop 4.0.1(Unity 的当前版本)使用 C#, 并且遇到了一个看似奇怪的语言。
这是我的整个 .cs 文件:
#if false
#define foo
#endif
class myClass {
int member;
}
#if false
#error this error does not trigger
#undef foo
// "cannot define or undefine preprocessor symbols after first token in file
#endif
我理解关于在声明令牌后不 #undef
预处理器符号的规则,但在这种情况下我 不 #undef
因为 #undef
在 #if false
.
此示例并非完全是人为设计的,它是尝试通过 here.
中描述的方法在 C# 和 C++ 中编译单个源文件Visual Studio 不会抱怨相同的代码。我认为您发现了 Mono 中的一个错误。