共用方式為


編譯器警告 (層級 3) C4267

'var': 將 'size_t' 轉換為 'type',資料可能遺失

編譯器偵測到從 size_t 轉換成較小的類型。

若要修正這項警告,請使用 size_t,而不是 type。 或者,使用至少與 size_t 一樣大的整數類型。

範例

下列範例會產生 C4267:

// C4267.cpp
// compile by using: cl /W4 C4267.cpp
void Func1(short) {}
void Func2(int) {}
void Func3(long) {}
void Func4(size_t) {}

int main() {
   size_t bufferSize = 10;
   Func1(bufferSize);   // C4267 for all platforms
   Func2(bufferSize);   // C4267 only for 64-bit platforms
   Func3(bufferSize);   // C4267 only for 64-bit platforms
   Func4(bufferSize);   // OK for all platforms
}