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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Declaring variables as 'new' in C++ CLR - Heap or GCHeap?

Declaring variables as 'new' in C++ CLR - Heap or GCHeap?

Scheduled Pinned Locked Moved Managed C++/CLI
c++dotnetquestion
2 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.
  • W Offline
    W Offline
    Will5801
    wrote on last edited by
    #1

    // IN C++ /clr // BOXED VALUE TYPE ON GC HEAP int ^ gc_i = gcnew int;           // WHAT EXACTLY IS THE STORAGE TYPE FOR THIS int ? int * i = new int; *i = 5; // PRESUMABLY ON THE UNMANAGED HEAP, BUT HOW CAN THIS HAPPEN FOR INT? // DOESN'T INT ALWAYS MAP TO System.Int32? // OR DOES THE COMPILER GIVE US A NATIVE INT INSTEAD, TO PLACE ON THE UNMANGED HEAP?

    M 1 Reply Last reply
    0
    • W Will5801

      // IN C++ /clr // BOXED VALUE TYPE ON GC HEAP int ^ gc_i = gcnew int;           // WHAT EXACTLY IS THE STORAGE TYPE FOR THIS int ? int * i = new int; *i = 5; // PRESUMABLY ON THE UNMANAGED HEAP, BUT HOW CAN THIS HAPPEN FOR INT? // DOESN'T INT ALWAYS MAP TO System.Int32? // OR DOES THE COMPILER GIVE US A NATIVE INT INSTEAD, TO PLACE ON THE UNMANGED HEAP?

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Will5801 wrote:

      // WHAT EXACTLY IS THE STORAGE TYPE FOR THIS int ?

      That's a native int on the CRT heap.

      Will5801 wrote:

      // PRESUMABLY ON THE UNMANAGED HEAP, BUT HOW CAN THIS HAPPEN FOR INT? // DOESN'T INT ALWAYS MAP TO System.Int32?

      You're using int in the native context (*, new) so the compiler can infer what int to use....the native one in this case.

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      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