Thanks for the help. It works, but I don't understand why.
For
void foo(short __gc& x)
why doesn't that mean that the arg must be on the managed heap, as opposed
to the local heap?
For
void foo(System::Int16& x)
isn't System::Int16 a structure? How can a reference to a structure be
equivalent to a reference to a basic type? Is it doing some implicit
marshaling going in and out of the foo()? I didn't see any implicit
conversion operator members in System::Int16.
Ian,
>For
> void foo(short __gc& x)
>why doesn't that mean that the arg must be on the managed heap, as opposed
>to the local heap?
__gc means slightly different things in different contexts. Here it
just makes it explicit that you want a managed reference.
>For
> void foo(System::Int16& x)
>isn't System::Int16 a structure? How can a reference to a structure be
>equivalent to a reference to a basic type?
Int16 is really the same as short int, except that the compiler knows
for sure that you're using it as a managed type, so pointers and
references to it are implicitly __gc.
Chapters 7 and 8 of the MC++ specification cover __gc pointers and
references in detail.
http://msdn.microsoft.com/library/en-us/vcmxspec/html/vcManagedExtensionsSpec_7.asp
The folks in microsoft.public.dotnet.languages.vc can probably explain
all this better than I can.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.