Compiling Unmanaged C++ Code as Managed Code

2k Views Asked by At

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.

1

There are 1 best solutions below

5
On BEST ANSWER

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.