Ошибка компилятора C3272
"символ": символу требуется атрибут FieldOffset, так как он является членом "имя типа", определенным с помощью StructLayout(LayoutKind::Explicit)
При использовании атрибута StructLayout(LayoutKind::Explicit)
необходимо помечать поля с помощью атрибута FieldOffset
.
Следующий пример приводит к возникновению ошибки 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_;
};