-
-
Save dandevelo/7a742d06c74c46ba67a141db1905d990 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
import macros | |
macro foo(x: static[string]): untyped = | |
var r: seq[uint8] = @[] | |
for i in 0 ..< x.len: | |
r.add x[i].uint8 | |
result = quote do: `r` | |
const | |
resources {.exportc.} = foo(staticRead"resources.bin") | |
# BUG? resources is generated as array[0..len, int] instead of array[0..len, uint8] | |
# the following code is needed for the const to be generated in the .C file | |
proc calcSum() = | |
var sum = 0 | |
for b in resources: | |
sum = sum + b | |
echo sum | |
calcSum() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment