Compiler Error C3749
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3749.
attribute': a custom attribute may not be used inside a function
A custom attribute cannot be used inside a function. (For more information on custom attributes, see the topic attribute.)
The following sample generates C3749:
// C3749a.cpp
// compile with: /clr /c
using namespace System;
[AttributeUsage(AttributeTargets::All)]
public ref struct ABC : public Attribute {
ABC() {}
};
void f1() { [ABC]; }; // C3749
The following sample generates C3749:
// C3749b.cpp
// compile with: /clr:oldSyntax /c
using namespace System;
[attribute(All)]
public __gc struct ABC {
ABC() {}
};
void f1() { [ABC]; }; // C3749
Show: