added system.unsafeAddr
This commit is contained in:
parent
f8f9677205
commit
ab26298a03
7 changed files with 48 additions and 16 deletions
19
tests/ccgbugs/tunsafeaddr.nim
Normal file
19
tests/ccgbugs/tunsafeaddr.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
discard """
|
||||
output: '''12'''
|
||||
"""
|
||||
|
||||
{.emit: """
|
||||
long sum(long* a, long len) {
|
||||
long i, result = 0;
|
||||
for (i = 0; i < len; ++i) result += a[i];
|
||||
return result;
|
||||
}
|
||||
""".}
|
||||
|
||||
proc sum(a: ptr int; len: int): int {.importc, nodecl.}
|
||||
|
||||
proc main =
|
||||
let foo = [8, 3, 1]
|
||||
echo sum(unsafeAddr foo[0], foo.len)
|
||||
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue