[Mono-dev] Marshalling (Segmentation fault)

russell.kay at realtimeworlds.com russell.kay at realtimeworlds.com
Thu Oct 11 11:38:24 EDT 2007


True,... 

In this case I was ripping an example I had that was using a union type
layout, which does need this type of arrangement... Apologies all round.

For simple structures C/C++ is pretty portable these days between
architectures, the main issue is 32bit/64bit and pointers (and any
alignment specific nastiness).

My main gripe with C# is not supporting union in a portable way (i.e.
you have to resort to LayoutKind.Explicit).

Russell


-----Original Message-----
From: mono-devel-list-bounces at lists.ximian.com
[mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Robert
Jordan
Sent: 11 October 2007 13:15
To: mono-devel-list at lists.ximian.com
Subject: Re: [Mono-dev] Marshalling (Segmentation fault)

russell.kay at realtimeworlds.com wrote:
> The C# version of this Structure would be best expressed as
> 
> [StructLayout(LayoutKind.Explicit)]
> unsafe struct FrameGrab
> {
> 	[FieldOffset(0)]
> 	public int bufferlength;
> 	[FieldOffset(4)]
> 	Public fixed IntPtr buffer[1000]
> }

This is usually bad portability-wise. LayoutKind.Sequential with
the system's ABI default packing should be used instead, unless
the struct really has a specific layout.

Robert

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

____________________________________________________________________
This email has been scanned by the MessageLabs Email Security System

DISCLAIMER
This message and any attachments contain privileged and confidential information intended for the use of the addressee named above. If you are not the intended recipient of this message, you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. Please note that we cannot guarantee that this message or any attachment is virus free or that it has not been intercepted and amended. The views of the author may not necessarily reflect those of Real Time Worlds Ltd.
____________________________________________________________________
This email has been scanned by the MessageLabs Email Security System



More information about the Mono-devel-list mailing list