-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructAlignment.cs
More file actions
28 lines (23 loc) · 775 Bytes
/
Copy pathStructAlignment.cs
File metadata and controls
28 lines (23 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Text;
using JSIL.Runtime;
using System.Runtime.InteropServices;
public static unsafe class Program {
public enum TestEnum : uint {
ERROR = 0x00000010,
WARNING = 0x00000020,
INFORMATION = 0x00000040
}
[StructLayout(LayoutKind.Sequential)]
public struct AlignmentStruct {
public ushort us;
public TestEnum choice;
}
[DllImport("common.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern AlignmentStruct TestAlignment(AlignmentStruct s);
public static void Main () {
var s = new AlignmentStruct { us = 1, choice = TestEnum.ERROR };
var s2 = TestAlignment(s);
Console.WriteLine("Result: {0} {1}", s2.us, s2.choice);
}
}