编译非托管 C++代码作为托管代码
我很久以前就编写了很多非托管 C++ 代码。现在,我想返回并使用 MS Test(内置于 Visual Studio 中)向该代码添加自动化测试。然而,为了做到这一点,我要么必须将 C++ 构建为 .lib 文件并在其周围编写一个包装层(以便从 C# 测试中调用它),要么需要能够将代码编译为托管代码。我已经解决了第一个选项,但理想情况下我更愿意使用第二个选项,这样就不需要包装层。请注意,尽管我提到用 C# 编写测试代码,但这不一定是必需的。
因此,我更改了项目的属性,将“公共语言运行时支持”属性从“无公共语言支持”更改为“公共语言运行时支持 (/clr)”。 现在当我尝试编译时,我收到一个错误,内容为“
"error D8016: '/ZI' and '/clr' command-line options are incompatible"
有人知道这真正意味着什么以及如何解决上述问题吗?”你以前做过这个吗?我已经在网上搜索和阅读它很长一段时间了,但我真的空手而归,没有真正的答案。
任何提示或建议将不胜感激。 谢谢。
I have a lot of unmanaged C++ code written quite some time ago. Now, I'm wanting to go back and add automated tests to that code using MS Test (built into Visual Studio). However, in order to do that, I either have to build the C++ as a .lib file and write a wrapper layer around it (in order to call it from C# tests) or I need to be able to compile the code as managed. The first option I've got worked out, but ideally I'd prefer to use the second option so that don't need the wrapper layer. Note, even though I mentioned writing the Test code in C#, that's not necessarily a requirement.
So, I changed the Project's properties such that the "Common Language Runtime Support" property changed from "No Common Language Support" to "Common Language Runtime Support (/clr)". Now when I try to compile, I get an error that reads
"error D8016: '/ZI' and '/clr' command-line options are incompatible"
Does anyone have idea what this really means and how I can work out the aforementioned problem? Have you done this before? I've been searching and reading about it online now for quite some time and I've really come away empty handed with no real answers.
Any tips or advice would be much appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/ZI
选项用于使用本机代码进行编辑并继续。请尝试使用非常相似的
/Zi
选项。无需编辑并继续功能即可调试数据库。The
/ZI
option is for edit-and-continue with native code.Try the very similar
/Zi
option instead. Debug database without the edit-and-continue feature.