Compiler Error C3156
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 C3156.
class' : you cannot have a local definition of a managed or WinRT type
A function cannot contain the definition, or declaration, of a managed or WinRT class, struct, or interface.
The following sample generates C3156.
// C3156.cpp
// compile with: /clr /c
void f() {
ref class X {}; // C3156
ref class Y; // C3156
}
The following sample generates C3156.
// C3156_b.cpp
// compile with: /clr:oldSyntax /c
void f() {
__gc class X {}; // C3156
__gc class Y; // C3156
}
Show: