编译器错误 C3270
“field”: FieldOffset 特性只能在 StructLayout(Explicit) 上下文中使用,在该情况下它是必需的
使用 FieldOffset 标记了一个字段,仅在 StructLayout(Explicit) 生效时允许使用该特性。
下面的示例生成 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
// ...
};
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈