Compiler Error C2472

 

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

function' cannot be generated in managed code: 'message'; compile with /clr to generate a mixed image

This error will occur when types not supported by managed code are used within a pure common language runtime (CLR) environment. Compile with /clr to resolve the error.

The following sample generates C2472.

// C2472.cpp  
// compile with: /clr:pure  
// C2472 expected  
  
#include <cstdlib>  
  
int main()  
{  
   int * __ptr32 p32;  
   int * __ptr64 p64;  
  
   p32 = (int * __ptr32)malloc(4);  
   p64 = p32;  
}  

/clr (Common Language Runtime Compilation)

Show: