编译器错误 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
};