在 VC++ .Net 中,Clr/Safe ( /clr:safe
) 和 Clr/Pure ( /clr:pure
) 是什么意思?
2 回答
从文档:
/clr:pure生成没有本机可执行代码的仅限 Microsoft 中间语言 (MSIL) 的输出文件。但是,它可以包含编译为 MSIL 的本机类型。
/clr:safe生成仅 MSIL(无本机可执行代码)、可验证的输出文件。/clr:safe 启用验证诊断(PEVerify Tool (Peverify.exe))。
I don't think that's enough information. It seemed from the other answer that it was just type checking. It seems from this doc that it's a lot more than that.
When
/clr
(not/clr:pure
or/clr:safe
) is used and__clrcall
is not used, taking the address of a function always returns the address of the native entry point function. When__clrcall
is used, the native entry point function is not created, so you get the address of the managed function, not an entry point thunk function. For more information, see Double Thunking.
/clr
(Common Language Runtime Compilation) implies that all functions and function pointers are__clrcall
and the compiler will not permit a function inside the compiland to be marked anything other than__clrcall
. When /clr:pure is used,__clrcall
can only be specified on function pointers and external declarations.