Export (0) Print
Expand All
Expand Minimize

Compiler Error C3272

Error Message

'symbol' : symbol requires FieldOffset, as it is a member of type typename defined with StructLayout(LayoutKind::Explicit)

When StructLayout Explicit is in effect, fields must be marked with FieldOffset.

The following sample generates 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_;
};

The following sample generates C3272:

// C3272.cpp
// compile with: /clr:oldSyntax /LD
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;

[StructLayout(LayoutKind::Explicit)]
__gc struct X
{
   int data_;   // C3272
   // try the following line instead
   // [FieldOffset(0)] int data_;
};

Community Additions

ADD
Show:
© 2015 Microsoft