编译器错误 C3451
“attribute”:不能将非托管特性应用于“type”
C++ 属性不能应用于 CLR 类型。 有关详细信息,请参阅 C++ 属性参考。
有关更多信息,请参见 User-Defined Attributes。
此错误可能是由于为 Visual Studio 2005 完成编译器一致性工作而导致:使用 CLR 编程的用户定义属性不再允许使用 uuid 属性。 请改用 GuidAttribute。
示例
下面的示例生成 C3451。
// C3451.cpp
// compile with: /clr /c
using namespace System;
[ attribute(AttributeTargets::All) ]
public ref struct MyAttr {};
[ MyAttr, helpstring("test") ] // C3451
// try the following line instead
// [ MyAttr ]
public ref struct ABC {};
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈