"Managed extensions" pinning question

  • Thread starter Thread starter Ioannis Vranos
  • Start date Start date
I

Ioannis Vranos

Consider the code:


wchar_t __pin *p= &(someCommand->ToCharArray())[0];

_wsystem(p);

p=0;




I need to pin the wchar_t __gc [] because I need to pass it to
_wsystem() which takes a wchar_t *.


Does the above code pin the whole wchar_t __gc[]?
 
Ioannis,
Consider the code:
wchar_t __pin *p= &(someCommand->ToCharArray())[0];

_wsystem(p);

p=0;

I need to pin the wchar_t __gc [] because I need to pass it to
_wsystem() which takes a wchar_t *.
Does the above code pin the whole wchar_t __gc[]?

Yep. From the MC++ spec, section 7.7 "Pinning Pointers":

"Pinning a sub-object defined in a managed object has the effect of pinning
the entire object. For example, if any element of an array is pinned, then
the whole array is also pinned. There are no extensions to the language for
declaring a pinned array. To pin an array, declare a pinning pointer to its
element type, and pin one of its elements.".
 
Tomas said:
Yep. From the MC++ spec, section 7.7 "Pinning Pointers":

"Pinning a sub-object defined in a managed object has the effect of pinning
the entire object. For example, if any element of an array is pinned, then
the whole array is also pinned. There are no extensions to the language for
declaring a pinned array. To pin an array, declare a pinning pointer to its
element type, and pin one of its elements.".


OK thanks. Where can I find that spec?
 
Ioannis said:
OK thanks. Where can I find that spec?

It's in the /vc7 directory of a Visual Studio .NET 2002/3 installation -
ManagedExtensionsSpec.doc

-cd
 
On a side note, it's not a very good idea to invest time on the old syntax.
You should try and move to the new C++/CLI syntax.
 
Nishant said:
On a side note, it's not a very good idea to invest time on the old
syntax. You should try and move to the new C++/CLI syntax.

Unless you plan to ship something in the next 9 months that is.

-cd
 
Back
Top