"Managed extensions" pinning question

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[]?
 
T

Tomas Restrepo \(MVP\)

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.".
 
I

Ioannis Vranos

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?
 
C

Carl Daniel [VC++ MVP]

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
 
N

Nishant S

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.
 
C

Carl Daniel [VC++ MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top