Compartir a través de


Error del compilador C3270

'field': el atributo FieldOffset solo se puede utilizar en el contexto de StructLayout(LayoutKind::Explicit), en cuyo caso es necesario

Se marcó un campo con FieldOffset, que solo se permite cuando StructLayout(Explicit) está activo.

El ejemplo siguiente genera la advertencia 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
   // ...
};