Last active
August 29, 2015 13:56
-
-
Save sayurin/9108129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nowarn "9" | |
open System.Runtime.InteropServices | |
[<Struct; StructLayout(LayoutKind.Explicit)>] | |
type s = | |
[<DefaultValue; FieldOffset 0>] | |
val mutable y : uint32 | |
[<DefaultValue; FieldOffset 0>] | |
val mutable x1 : byte | |
[<DefaultValue; FieldOffset 1>] | |
val mutable x2 : byte | |
[<DefaultValue; FieldOffset 2>] | |
val mutable x3 : byte | |
[<DefaultValue; FieldOffset 3>] | |
val mutable x4 : byte | |
do | |
let t = s(x1 = 1uy, x2 = 2uy, x3 = 3uy, x4 = 4uy) | |
printfn "%x" t.y | |
do | |
let t = s(y = 0x01020304u) | |
printfn "%x %x %x %x" t.x1 t.x2 t.x3 t.x4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment