Edit

Share via


Compiler Error C3271

'member': invalid value 'value' for the FieldOffset attribute

A negative number was passed to the FieldOffset attribute.

The following sample generates C3271:

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

[StructLayout(LayoutKind::Explicit)]
value class MyStruct1 {
   public: [FieldOffset(0)] int a;
   public: [FieldOffset(-1)] long b;   // C3271
};