編譯器錯誤 C3272
'symbol' : 符號必須有 FieldOffset,因為它是用 StructLayout(LayoutKind::Explicit) 定義的類型 typename 的成員
當 StructLayout(LayoutKind::Explicit)
生效時,欄位必須標記為 FieldOffset
。
下列範例會產生 C3272:
// C3272_2.cpp
// compile with: /clr /c
using namespace System;
using namespace System::Runtime::InteropServices;
[StructLayout(LayoutKind::Explicit)]
ref struct X
{
int data_; // C3272
// try the following line instead
// [FieldOffset(0)] int data_;
};