簡體   English   中英

似乎在#if錯誤塊中評估預處理程序代碼

[英]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 ing,因為#undef#if false內部。

這個示例並非完全是人為設計的,它是嘗試通過此處描述的方法使單個源文件在C#和C ++中進行編譯。

Visual Studio不會抱怨相同的代碼。 我認為您已經在Mono中發現了一個錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM