转换 c++项目到 clr 安全项目
我需要将一个非常大的 C++ 项目转换为 clr 安全项目。当前的 C++ 项目有很多来自 C++ 的东西,如模板、泛型、指针、存储/流、ole api、zlib 压缩 api、内联等。在哪里可以找到这种类型转换的详细文档?能推荐一些好书可以参考吗?如果你们中有人做过这样的转换,我可以向您提供一些分析吗?
I need to work on converting a very huge c++ project to clr safe. The current c++ project has a lot of stuff from c++ like templates, generics, pointers, storage/stream, ole apis, zlib compression apis, inlines etc. Where can I find the datiled document for this type of conversion? Can you suggest some good book to refer to? If anyone of you have done such conversion, can I get some analysis from you?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我将直接引用标题为“如何:迁移到 /clr:safe
Visual C++ 可以使用 /clr:safe 生成可验证组件,这会导致编译器为每个不可验证代码构造生成错误”
的 MSDN 库文章 。以下问题会产生可验证性错误:
另外,以下关键字不能在可验证的代码中使用:
我认为这会让您忙碌一段时间。没有什么魔杖可以将原生 C++ 转换为可验证的代码。你确定这值得投资吗?
I'll just cough up the MSDN Library article titled "How to: Migrate to /clr:safe
Visual C++ can generate verifiable components with using /clr:safe, which causes the compiler to generate errors for each non-verifiable code construct.
The following issues generate verifiability errors:
Also, the following keywords cannot be used in verifiable code:
I reckon that will keep you busy for a while. There is no magic wand to wave to turn native C++ into verifiable code. Are you sure this is worth the investment?
绝大多数本机 C++ 是完全有效的 C++/CLI,包括模板、内联等,但 CLR STL 与 BCL 相比相当慢。此外,原生 C++ 没有泛型,只有模板。
C++/CLI 编译的实际情况是检查开关并推送编译,并等待它抛出错误。
The vast majority of native C++ is entirely valid C++/CLI, including templates, inlines, etc, except the CLR STL is rather slow compared to the BCL. Also, native C++ doesn't have generics, only templates.
The reality of compiling as C++/CLI is to check the switch and push compile, and wait for it to throw errors.
将本机 C++ 重写为安全 C++/CLI 将生成语法上不同但语义上与 C# 相同的代码。既然如此,为什么不直接用C#重写呢?
如果您想避免本质上完全重写,请考虑以下替代方案:
Rewriting native C++ into safe C++/CLI will result in a code that is syntactically different, but semantically same as C#. If that is the case, why not rewrite directly in C#?
If you want to avoid what is essentially a complete rewrite, consider the following alternatives: