共用方式為


編譯器警告 (層級 4) C4242

'identifier' : 將 'type1' 轉換為 'type2',資料可能遺失

型別是不同的。 型別轉換可能會造成資料的遺失。 編譯器進行型別轉換。

此警告在預設情況下為關閉的。 如需詳細資訊,請參閱預設為關閉的編譯器警告

如需 C4242 的額外資訊,請參閱常見編譯器錯誤

下列範例會產生 C4242:

// C4242.cpp
// compile with: /W4
#pragma warning(4:4242)
int func() {
   return 0;
}

int main() {
   char a;
   a = func();   // C4242, return type and variable type do not match
}