编译器错误 C3271
“member”:FieldOffset 特性的值“value”无效
将一个负数传递到了 “FieldOffset” 特性。
以下示例生成 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
};