编译器错误 C3749

“attribute”: 自定义属性不能在函数内部使用

不能在函数内部使用自定义属性。 有关自定义属性的详细信息,请参阅属性主题。

示例

以下示例生成 C3749:

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

[AttributeUsage(AttributeTargets::All)]
public ref struct ABC : public Attribute {
   ABC() {}
};

void f1() { [ABC]; };  // C3749