Created
July 13, 2020 01:18
-
-
Save SeaniaTwix/04da16629fe1397250570c18c1fd87f4 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
proc toByteArrayPtr[L, T](i: T): ptr array[L, uint8] = | |
result = array[L, uint8].create() | |
for n in 0..<sizeof(i): | |
var | |
j = i | |
v = cast[ptr uint8](addr(j) + n) | |
result[n] = v[] | |
when isMainModule: | |
discard toByteArrayPtr[8, int32](123) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment