Partilhar via


Erro do compilador C3095

'atributo': atributo não pode ser repetido

Observações

Alguns atributos são declarados de tal forma que, várias ocorrências do atributo não podem ser aplicadas a um destino.

Para obter mais informações, consulte atributos definidos pelo utilizador.

Example

O exemplo a seguir gera C3095.

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

[AttributeUsage(AttributeTargets::All, AllowMultiple=false)]
public ref class Attr : public Attribute {
public:
   Attr(int t) : m_t(t) {}
   const int m_t;
};

[AttributeUsage(AttributeTargets::All, AllowMultiple=true)]
public ref class Attr2 : public Attribute {
public:
   Attr2(int t) : m_t(t) {}
   const int m_t;
};

[Attr(10)]   // C3095
[Attr(11)]
ref class A {};

[Attr2(10)]   // OK
[Attr2(11)]
ref class B {};