编译器警告(等级 3)C4580

[attribute] 已弃用;改为指定 System::Attribute 或 Platform::Metadata 作为基类

[attribute] 不再是创建用户定义的特性的首选语法。 有关更多信息,请参见 User-Defined Attributes。 对于 CLR 代码,请从 System::Attribute 派生特性。 对于 Windows 运行时代码,请从 Platform::Metadata 派生特性。

示例

下面的示例将生成 C3454,并演示如何修复此错误。

// C4580.cpp
// compile with: /W3 /c /clr
[attribute]   // C4580
public ref class Attr {
public:
   int m_t;
};

public ref class Attr2 : System::Attribute {
public:
   int m_t;
};