编译器警告(等级 1)C4747
调用托管“entrypoint”: 托管代码可能不会在加载程序锁定下运行,包括 DLL 入口点和从 DLL 入口点访问到的调用
编译器发现 (可能) DLL 入口点编译为 MSIL。 由于加载已将入口点编译为 MSIL 的 DLL 的潜在问题,因此强烈建议不要将 DLL 入口点函数编译到 MSIL。
有关详细信息,请参阅混合程序集的初始化和链接器工具错误 LNK1306。
更正此错误
请勿使用 /clr 编译模块。
使用
#pragma unmanaged
标记入口点函数。
示例
下面的示例生成 C4747。
// C4747.cpp
// compile with: /clr /c /W1
// C4747 expected
#include <windows.h>
// Uncomment the following line to resolve.
// #pragma unmanaged
BOOL WINAPI DllMain(HANDLE hInstance, ULONG Command, LPVOID Reserved) {
return TRUE;
};