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. Confusing between Native and Managed !??

Confusing between Native and Managed !??

Scheduled Pinned Locked Moved Managed C++/CLI
questionc++dotnetdata-structures
3 Posts 2 Posters 0 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
    anti AS
    wrote on last edited by
    #1

    Hi If i use /clr mode to compile a code that has somthing like the following:

    int x = 3;
    char ch='A';
    int arr[]="Hi";
    array^ ManArr1={44};
    array^ ManArr2= gcnew array {44};

    my questions now: Would the type int be mapped to System::Int32 ?? and what about char ch ? Are they considerd as native or managed type? Where will be executed! through MSIL or not!! We see that int arr[] is a native array, does that mean it will be executed out of MSIL?:confused: The last question ;) ,, For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ??

    N 1 Reply Last reply
    0
    • A anti AS

      Hi If i use /clr mode to compile a code that has somthing like the following:

      int x = 3;
      char ch='A';
      int arr[]="Hi";
      array^ ManArr1={44};
      array^ ManArr2= gcnew array {44};

      my questions now: Would the type int be mapped to System::Int32 ?? and what about char ch ? Are they considerd as native or managed type? Where will be executed! through MSIL or not!! We see that int arr[] is a native array, does that mean it will be executed out of MSIL?:confused: The last question ;) ,, For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ??

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Good question!

      anti.AS wrote:

      Would the type int be mapped to System::Int32

      Yes. By default compiler treat it as managed integer. And what type of interger is implementation defined. On a 32 bit machine you could get System.Int32 and Int64 on 64 bit machines. Now consider the following example

      int x = 3;
      std::cout << x;

      std::cout expects a native integer and you are passing a managed one. So the compiler does the conversion for you.

      anti.AS wrote:

      and what about char ch ?

      This will be compiled as System.SByte.

      anti.AS wrote:

      We see that int arr[] is a native array

      int arr[]="Hi"; is an invalid statement. But in general, this is treated as a managed CLI array.

      anti.AS wrote:

      The last question Wink ,, For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ??

      Nothing. First one is a syntactic sugar. Hope that helps :)

      Best wishes, Navaneeth

      A 1 Reply Last reply
      0
      • N N a v a n e e t h

        Good question!

        anti.AS wrote:

        Would the type int be mapped to System::Int32

        Yes. By default compiler treat it as managed integer. And what type of interger is implementation defined. On a 32 bit machine you could get System.Int32 and Int64 on 64 bit machines. Now consider the following example

        int x = 3;
        std::cout << x;

        std::cout expects a native integer and you are passing a managed one. So the compiler does the conversion for you.

        anti.AS wrote:

        and what about char ch ?

        This will be compiled as System.SByte.

        anti.AS wrote:

        We see that int arr[] is a native array

        int arr[]="Hi"; is an invalid statement. But in general, this is treated as a managed CLI array.

        anti.AS wrote:

        The last question Wink ,, For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ??

        Nothing. First one is a syntactic sugar. Hope that helps :)

        Best wishes, Navaneeth

        A Offline
        A Offline
        anti AS
        wrote on last edited by
        #3

        Thank u N a v a n e e t h... great information ... btw the native array will be considered as unverifiable unlike the managed one. ;)

        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