Compiler Error C3270
'field': the FieldOffset attribute can only be used in the context of StructLayout(Explicit), in which case it is required
A field was marked with FieldOffset, which is only allowed when StructLayout(Explicit) is in effect.
The following sample generates 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
// ...
};
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for