[Mono-dev] Re: StructLayout with misaligned offsets

tcmichals tcmichals at msn.com
Wed Apr 12 14:18:37 EDT 2006


I'm also using the same method on other struct's and getting different sizes 
between mono 1.1.14 and 2.0 .NET, the .NET version is giving me the correct 
sizes, would this also be considered the same issue?

I'm trying use the StructLayout to overlay the same data structures used 
bettwen C++ and C#.
"Zoltan Varga" <vargaz at gmail.com> wrote in message 
news:295e750a0604120928reebc06eh1e00f61496fb8123 at mail.gmail.com...
            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