Sdílet prostřednictvím


Chyba kompilátoru C3104

neplatný argument atributu

Poznámky

Zadali jste neplatný argument atributu.

Další informace najdete v části Typy parametrů atributů.

Tuto chybu lze vygenerovat v důsledku práce v souladu kompilátoru, která byla provedena pro Visual Studio 2005: při předávání spravovaných polí vlastním atributům se typ pole už nezpůsobí ze seznamu agregace inicializace. Kompilátor teď vyžaduje, abyste zadali typ pole i seznam inicializátorů.

Příklady

Následující příklad vygeneruje C3104.

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

[AttributeUsage(AttributeTargets::Class)]
public ref struct ABC : public Attribute {
   ABC(array<int>^){}
   array<double> ^ param;
};

[ABC( {1,2,3}, param = {2.71, 3.14})]   // C3104
// try the following line instead
// [ABC( gcnew array<int> {1,2,3}, param = gcnew array<double>{2.71, 3.14})]
ref struct AStruct{};

Následující příklad vygeneruje C3104.

// C3104b.cpp
// compile with: /clr /c
// C3104 expected
using namespace System;

int func() {
   return 0;
}

[attribute(All)]
ref class A {
public:
   A(int) {}
};

// Delete the following 2 lines to resolve.
[A(func())]
ref class B {};

// OK
[A(0)]
ref class B {};