次の方法で共有


コンパイラ エラー C3272

'symbol': シンボルは、StructLayout(LayoutKind::Explicit) で定義された型パラメーターのメンバーであるため、このシンボルには FieldOffset が必要です

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_;
};