共用方式為


編譯器警告 (層級 4,關閉) C4062

'enum' 的 switch 中未處理列舉程式 'identifier'

備註

列舉程式識別碼case 陳述式中沒有與其相關聯的 switch 處理程式,且沒有可攔截其的 default 標籤。 遺漏的情況可能為疏失,且為程式碼中的潛在錯誤。 如需具有 switch 案例之 default 陳述式中未使用的列舉程式的相關警告,請參閱 C4061

此警告預設為關閉。 如需如何啟用預設關閉之警告的詳細資訊,請參閱預設關閉的編譯程式警告

範例

下列範例會產生 C4062,並示範如何修正它:

// C4062.cpp
// compile with: /EHsc /W4
#pragma warning(default : 4062)
enum E { a, b, c };
void func ( E e ) {
   switch(e) {
      case a:
      case b:
   // case c:  // to fix, uncomment this line
      break;   // no default label
   }   // C4062, enumerator 'c' not handled
}

另請參閱

編譯器警告 (層級 4) C4061