Compiler Error C3150

 

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 C3150.

element' : 'attribute' can only be applied to a class, interface, array or pointer

__gc can only be used on a class, interface, or array.

C3150 is only reachable using /clr:oldSyntax.

The following sample generates C3150:

// C3150.cpp  
// compile with: /clr:oldSyntax  
#using <mscorlib.dll>  
  
__gc void f()   // C3150; function cannot be managed  
{  
}  

Show: