如何将 C++/CLI 代码的某些部分编译为本机而将某些部分编译为托管?
我正在调用 LoadTypeLib 以在 C++/CLI 中加载非托管类型库。我需要将一些代码区域编译为托管代码区域,将一些代码区域编译为非托管(本机),并形成一个混合模式类库作为可执行文件。
我需要托管和非托管(本机)哪些部分才能分别编译为托管和本机?
I am calling LoadTypeLib for loading unmanaged type libraries in C++/CLI. I need to compile some code areas as managed and some code areas as unmanaged (native) and form a mixed mode class library as executable.
What part do I need to be managed and unmanaged (native) to compile as managed and native respectively?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
#pragma Managed
更喜欢使用
#pragma Managed
进行推送和开/关,然后弹出,#pragma unmanaged
实际上没什么用。#pragma managed
Prefer using
#pragma managed
with push and on/off, then pop,#pragma unmanaged
is actually quite useless.不要使用 #pragma Managed - 它被认为是“邪恶的”并且可能会导致 DLL 初始化/关闭问题。
我建议显式地将一些文件编译为托管文件 (/clr),将一些文件编译为本机文件(不带 /clr)。您还可以有两个预编译标头 - 一个用于托管,一个用于本机。
Don't use #pragma managed - it's considered "evil" and may cause problems with DLL init/shutdown.
I would recommend explicitly compiling some files as managed (/clr), and some as native (without /clr). You can also have two pre-compiled headers - one for managed, one for native.