2010-04-19 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / tests / pack-layout.cs
blobf149cc360405f7a5cbebc427264e50ab09ced91c
1 using System;
2 using System.Runtime.InteropServices;
4 [StructLayout ( LayoutKind.Sequential, Pack=2 )]
5 struct MYStruct {
6 short a;
7 int b;
10 [StructLayout ( LayoutKind.Sequential, Pack=2 )]
11 struct MYStruct2 {
12 int b;
13 short a;
16 struct MYStruct3 {
17 int b;
18 short a;
21 class Test {
22 static int Main() {
23 int ms, ms2, ms3;
24 unsafe {
25 ms = sizeof (MYStruct);
26 ms2 = sizeof (MYStruct2);
27 ms3 = sizeof (MYStruct3);
29 Console.WriteLine ("MYStruct size: {0}", ms);
30 Console.WriteLine ("MYStruct2 size: {0}", ms2);
31 Console.WriteLine ("MYStruct3 size: {0}", ms3);
32 if (ms != 6)
33 return 1;
34 if (ms2 != 6)
35 return 2;
36 if (ms3 != 8)
37 return 3;
38 return 0;