[Mono-dev] StructLayout with misaligned offsets
Zoltan Varga
vargaz at gmail.com
Wed Apr 12 12:28:54 EDT 2006
Hi,
This is a known bug and it is tracked as:
http://bugzilla.ximian.com/show_bug.cgi?id=77788
Zoltan
On 4/12/06, tcmichals <tcmichals at msn.com> wrote:
> namespace testCode
> {
> class Program
> {
> [StructLayout(LayoutKind.Sequential, Pack = 1 /*, CharSet =
> CharSet.Ansi */)/*, Serializable*/]
> public struct tagSDK
> {
>
> [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
> public ushort[] inter;
> public ushort integ;
> public ushort mode;
> public ushort imaging;
> [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
> public ushort[] Avg;
> public ushort numOfIntervals;
> public tagSDK(int val)
> {
> this.inter = new ushort[12];
> this.inter[0] = 0;
> this.Avg = new ushort[12];
> Avg[0] = 0;
> integ = 0;
> imaging = 0;
> imaging2 = 0;
> numOfIntervals = 0;
> mode = 0;
> }
> };
> static void Main(string[] args)
> {
> tagSDK t= new tagSDK(0);
> Console.WriteLine("Hello World");
> }
> }
> }
>
> When I attempt to execute the following program the following message is
> generated
> * ERROR **: file object.c: line 509 (compute_class_bitmap): assertion
> failed: ((field->offset % sizeof(gpointer)) == 0)
>
> If I change The alignment of Avg to be on a 4 byte boundry it works,
> sugguestions?
>
>
>
>
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
More information about the Mono-devel-list
mailing list