Understanding Managed C ++

I am having trouble understanding how managed C ++ works and compiles.

In the .NET Framework, you can develop code in C # / VB / F # / .. etc. and all of these languages ​​will be compiled into the same Common Intermediate Language (CIL), which is similar to Java Bytecode. Theoretically, CIL can be installed on any platform (Mono did it in practice). On Windows, the CLR compiles CIL into its own Just-In-Time (JIT) code, and everything works smoothly and well.

Now, how is Managed C ++ compiled? Will it compile the CIL code and wait for the CLR to run it using JIT? I think not, because Managed C ++ can use standard C ++ code (which is not compiled for CIL). Moreover, how can it use .NET assemblies (which are CIL)?

I would appreciate any help. Thanks

EDIT:

I saw this answer . He notes that in C ++ / CLI, managed code compiles to MSIL, and you have the option of compiling unmanaged code to either native code or MSIL. So now I understand how .NET assemblies can be called.

In any case, I still do not understand how unmanaged C ++ code can work with managed code in the same assembly if the unmanaged code was compiled into native code. Any ideas?

+4
source share
2 answers

. , . , .

, .NET( CIL)?

CIL, . .NET metadata + msil, . , , . , ++. , . .NET + msil - . , . CLR .

... ++ ( CIL)

, ++ msil . , , , /clr #pragma, . CIL , , -, Java JVM. ++-, ++. , pinvoke ( , ). , ++- msil. , , ( ) - . .

CIL - , ++ () ( ). , , ++, LLVM (, Clang). .NET , LLVM .


, , ( ). . , , ++ . - , , . , , , , .

, . , , #, , ++, . , unsafe. ++/CLI, .

- , msil. , . , , . . GC , , .

+6

Manged ++ . , ++ Manged, ++\CLI. CLR, .net. , .NET .NET, :

using namespace System;
0

Source: https://habr.com/ru/post/1670857/


All Articles