Created
September 13, 2018 00:18
-
-
Save ear7h/454223c3b63a80ed0802b6d778060993 to your computer and use it in GitHub Desktop.
reading in a struct (with only static sized types) in Nim
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
type | |
SomeStruct = object | |
longPtr: uint64 | |
length: uint32 | |
var x: ptr SomeStruct | |
var dat: array[12, char] | |
for ch in mitems(dat): | |
ch = high(char) | |
x = cast[ptr SomeStruct](addr(dat)) | |
echo $x.length | |
echo $high(uint32) # confirm correctness | |
x.length = 0 | |
echo $dat # check if it works the other way |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment