hello

you can obtain pointer only for value type, array or string. The first element of an 
array must to be a value type.

Arnaud


> in continuation with this,
> is there any way of taking the address of a managed type,
> like for example when i tried to compile similar code:
> 
> class testobj {
>  public int y;
> }
> 
> class Foo {
>  public testobj x;
> }
> 
> unsafe class test {
>  public static void Main()
>  {
>   Foo foo=Foo();
>   fixed(testobj* f=&foo.x) {
>   ...
> 
>   }
> 
> 
>  }
> 
> 
> }
> 
> i got a compiler error "cannot take address of a managed type"
> for the line having the fixed stmt (both on windows and Free BSD, rotor
> Beta version)
> am i missing something here?
> 
> thanks,
> archana
> 
> 
> On Tue, 3 Jun 2003, Jan Kotas wrote:
> 
> > Only variable z is marked as pinned. It is easy to see if you look at
> > generated IL using ildasm.
> >
> > The pinned pointers will show up as interior pointers during the GC
> > scan. For interior pointers, the GC uses bricktable to find the object
> > that encapsulates the given memory location and then operates on that.
> > If you want to see it in the code, look for GC_CALL_INTERIOR flag and
> > what's done differently when it is set.
> >
> > So to answer your question, when a field in the object is pinned the
> > whole object will be pinned. This will happen inside the GC through
> > interior pointers. There does not have to be pinned variable holding
> > reference to the object.
> >
> > -Jan
> >
> > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> >
> > -----Original Message-----
> > From: Discussion of the Rotor Shared Source CLI implementation
> > [mailto:[EMAIL PROTECTED] On Behalf Of Archana
> > Sent: Tuesday, January 05, 1999 10:01 AM
> > To: [EMAIL PROTECTED]
> > Subject: [DOTNET-ROTOR] pinning and fixed blocks
> >
> > Hi,
> >  this is regarding Pinning objects using fixed(..) {}
> > If we have a piece of code like
> > fixed (obj* z= & objx.field) {
> > ...
> > }
> > How does rotor treat the variables z and obj,
> > does it mark both as pinned?
> > when it pins objx does it pin just the field or the entire object?
> >
> > regards
> >
> 
> 
> 

------------------------------------------

Faites un voeu et puis Voila ! www.voila.fr 

Reply via email to