W
William DePalo [MVP VC++]
Bonj said:As I've got in my project. And the unmanaged function is called seamlessly
from the (completely) unmanaged extended proc. DLL project, and it
seamlessly
creates an instance of a managed object (System::String).
But I've heard about this thing called IJW which is whereby they say "you
can take your existing C++ code, but compile it under .NET as managed
code -
no changes to be made".
Where code generation is concerened, the compile is a lot smarter than most
of us who use it. In this article,
http://msdn.microsoft.com/msdnmag/issues/04/05/VisualC2005/default.aspx
Steven Toub says this
<quote>
The only code that is generated as native machine code is code that just
can't be compiled to MSIL, including functions with inline asm blocks and
operations that use CPU-specific intrinsics such as Streaming SIMD
Extensions (SSE). The /clr switch is how the Quake II port to .NET was
accomplished. The Vertigo software team spent a day porting the original C
code for the game to code that successfully compiled as C++ and then threw
the /clr switch. In no time they were up and running on the .NET Framework.
Without adding any additional binaries and simply by including the
appropriate header files, managed C++ and native C++ can call each other
without any additional work on the part of the developer. The compiler
handles the creation of the appropriate thunks to go back and forth between
the two worlds.
Do my unmanaged functions compile to *actual* unmanaged (i.e. non-MSIL)
machine code,
That depends. See above.
So how does it know that's not what I want to do, and
what if I *did* want to do that, how would I do it?
I'm not sure what "it" is here. Where interoperability is concerned, the
details make all the difference so if there is something that you need to do
you might want to ask a detailed question. To be fair, I should point out
that there are "issues" as the article above calls them. That is there are
cases where you might not want to rely on the compiler but rather take
charge yourself.
Regards,
Will