ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Intro to Managed C++, Part 2: Mixing Managed and Unmanaged Code
Subject:   Pinning a stack variable?
Date:   2003-04-10 10:47:39
From:   anonymous2
Is it really necessary to pin an int before passing a pointer to it to unmanaged code here:


void SetValue(int val)
{
int someValue = val;
int __pin* pinnedInt = &someValue;
pContainer->SetValue(pinnedInt);
}


Isn't someValue a "value" type? In this case doesn't this value type live on the stack with no danger of moving? What is the point of pinning something that cannot move?


-Bern McCarty