编译器错误 C2472
“function”无法在托管代码“message”中生成;请使用 /clr 进行编译以生成混合映像
备注
当在纯公共语言运行库 (CLR) 环境中使用托管代码不支持的类型时,将出现此错误。 请使用 /clr 进行编译以解决该错误。
“/clr:pure”和“/clr:safe”编译器选项在 Visual Studio 2015 中已弃用,并且在 Visual Studio 2017 中不受支持。
示例
下面的示例生成 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;
}