Skip to content

Instantly share code, notes, and snippets.

@SeaniaTwix
Created July 13, 2020 01:18
Show Gist options
  • Save SeaniaTwix/04da16629fe1397250570c18c1fd87f4 to your computer and use it in GitHub Desktop.
Save SeaniaTwix/04da16629fe1397250570c18c1fd87f4 to your computer and use it in GitHub Desktop.
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