Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / pack-layout.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 [StructLayout ( LayoutKind.Sequential, Pack=2 )]
5 struct MYStruct  {
6         short a;
7         int b;
8 }
9
10 [StructLayout ( LayoutKind.Sequential, Pack=2 )]
11 struct MYStruct2  {
12         int b;
13         short a;
14 }
15
16 struct MYStruct3  {
17         int b;
18         short a;
19 }
20
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);
28                 }
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;
39         }
40 }