编译器错误 C3342

“attribute”:不明确的特性

编译器发现特性的多个定义。

多次定义了特性。

有关更多信息,请参见 User-Defined Attributes

示例

以下示例生成 C3342。

// C3342.cpp
// compile with: /clr /c
using namespace System;
using namespace System::Reflection;

[AttributeUsage(AttributeTargets::All)]
public ref class XAttribute : public  Attribute {};

[AttributeUsage(AttributeTargets::All)]
public ref class X : public Attribute {};

[X]   // C3342 could refer to X or XAttribute
// try the following line instead
// [XAttribute]
public ref class Class4 {};