次の方法で共有


コンパイラ エラー C3270

'field': FieldOffset 属性は、必要な場合は StructLayout(Explicit) のコンテキストでのみ使用できます

フィールドが FieldOffset でマークされていますが、これは StructLayout (Explicit) が有効になっている場合にのみ使用できます。

次の例では C3270 が生成されます。

// C3270_2.cpp
// compile with: /clr /c
using namespace System::Runtime::InteropServices;

[ StructLayout(LayoutKind::Sequential) ]
// try the following line instead
// [ StructLayout(LayoutKind::Explicit) ]
public value struct MYUNION
{
   [FieldOffset(0)] int a;   // C3270
   // ...
};