Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Mixing managed and unmanaged code

Mixing managed and unmanaged code

Scheduled Pinned Locked Moved Managed C++/CLI
questioncsharpc++dotnetlearning
6 Posts 2 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alexandru Savescu
    wrote on last edited by
    #1

    Suppose I have an old application with unmanaged code and I adding some .NET classes that are of course managed. The question is: Will my unmanaged code be compiled as native code and the managed code will be CLR metadata? I am asking this, because I want my old, unmanaged part of application to be very fast, not a MSIL that is at first run (?) compiled into native code. Best regards, Alexandru Savescu

    N 1 Reply Last reply
    0
    • A Alexandru Savescu

      Suppose I have an old application with unmanaged code and I adding some .NET classes that are of course managed. The question is: Will my unmanaged code be compiled as native code and the managed code will be CLR metadata? I am asking this, because I want my old, unmanaged part of application to be very fast, not a MSIL that is at first run (?) compiled into native code. Best regards, Alexandru Savescu

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Use #pragma unmanaged to specify that the following code is to be compiled to native code and #pragma managed when you end the native stuff


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)

      A 1 Reply Last reply
      0
      • N Nish Nishant

        Use #pragma unmanaged to specify that the following code is to be compiled to native code and #pragma managed when you end the native stuff


        Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)

        A Offline
        A Offline
        Alexandru Savescu
        wrote on last edited by
        #3

        Thanks Nish! However what if I want to declare a managed type inside of an existing class? Will then my whole class be managed? (This is something that I would not like :) ) Best regards, Alexandru Savescu

        N 1 Reply Last reply
        0
        • A Alexandru Savescu

          Thanks Nish! However what if I want to declare a managed type inside of an existing class? Will then my whole class be managed? (This is something that I would not like :) ) Best regards, Alexandru Savescu

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          ****Alexpro wrote: Will then my whole class be managed? (This is something that I would not like ) No. If you want to use a managed type inside say your CDialog class, then you'll have to only add #pragma managed for the function in the class, where you use the managed type. That was how it was in Beta 2. I didn't chk to see if it allows you to have a managed line of code inside an unmanaged marked function. I should think not! Nish


          Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)

          A 1 Reply Last reply
          0
          • A Alexandru Savescu

            Nish - Native CPian wrote: if it allows you to have a managed line of code inside an unmanaged marked function. I should think not! It doesn't! Best regards, Alexandru Savescu

            N Offline
            N Offline
            Nish Nishant
            wrote on last edited by
            #5

            ****Alexpro wrote: It doesn't! Well, at least, they granularised at the function level instead of at the class level which would have been horrible. Nish :-)


            Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)

            1 Reply Last reply
            0
            • N Nish Nishant

              ****Alexpro wrote: Will then my whole class be managed? (This is something that I would not like ) No. If you want to use a managed type inside say your CDialog class, then you'll have to only add #pragma managed for the function in the class, where you use the managed type. That was how it was in Beta 2. I didn't chk to see if it allows you to have a managed line of code inside an unmanaged marked function. I should think not! Nish


              Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)

              A Offline
              A Offline
              Alexandru Savescu
              wrote on last edited by
              #6

              Nish - Native CPian wrote: if it allows you to have a managed line of code inside an unmanaged marked function. I should think not! It doesn't! Best regards, Alexandru Savescu

              N 1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups