次の方法で共有


コンパイラ エラー C2364

'type': カスタムの属性として不適切な型です

カスタム属性の名前付き引数は、コンパイル時の定数に制限されます。 たとえば、整数型 (int、char など)、System::Type^、System::Object^ などです。

次の例では C2364 が生成されます。

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

[attribute(AttributeTargets::All)]
public ref struct ABC {
public:
   // Delete the following line to resolve.
   ABC( Enum^ ) {}   // C2364
   ABC( int ) {}   // OK
};