0
votes

I have a C# project and I need a C++ native code to interact with the C# code. To do so, I am using a C++/CLI class wrapper that will call a C++ class.

As far as I understand, if a C++ class has a ref behind it's declaration, it's going to be compiled as managed code. And if it doesn't have it, it will be compiled as native code.

Is this assumption correct or do I need to give the compiler further instructions to assure that my class will be native code?

1
"if a C++ class has a ref...it's going to be compiled as managed code" - Not sure about that. A c++/CLI ref class can contain both native and CLI types. e.g. A ref class that has a void* pointer in it. blogs.msdn.com/b/abhinaba/archive/2012/11/14/…Micky
Anyone cares to point out why the -1 votes?Michel Feinstein
Could be angry C++ coders emphasizing the "How the expletive deleted should I know? That's not a C++ question." There's no such thing as ref in C++.user4581301
I asked a question with the title and tag c++/cli, so it covers both languages and the ref modifierMichel Feinstein
I will read that article, thanks @MickyMichel Feinstein

1 Answers

4
votes

As far as I understand, if a C++ class has a ref behind it's declaration, it's going to be compiled as managed code.

Correct. ref class types cannot be compiled without /clr.

And if it doesn't have it, it will be compiled as native code.

Incorrect. If /clr is in effect (e.g. not disabled by #pragma unmanaged) then the compiler is only generating MSIL (Microsoft intermediate language, the bytecode for .NET).