lostanza let :
call-c clib/printf("Hello world\n")
Don't use pointers to variables on the stack
public lostanza defn libarchive_read_data_block (p:ref<LIBARCHIVE>, pbuf:ptr<ptr<?>>, psize:ptr<long>, poffset:ptr<long>) -> ref<Long> :
var xbuf:ptr<?>
var xs:long
var xo:long
val rtn:long = call-c archive_read_data_block(p.la-ptr, addr(xbuf), addr(xs), addr(xo))
return new Long{0}
This throws:
FATAL ERROR: No appropriate branch for arguments of type (Int).
in core/print-stack-trace
at core/core.stanza:344.14
in core/fatal
at core/core.stanza:397.2
in core/no-branch-error
at core/core.stanza:274.2
in stz/el-to-vm/Compiler/imms!
at compiler/el-to-vm.stanza:793.10
...
This is because we can't create pointers to values on the stack. Need to use malloc/free to create them on the heap.
Calling lostanza from repl
This works:
Don't use pointers to variables on the stack
This throws:
This is because we can't create pointers to values on the stack. Need to use
malloc/free
to create them on the heap.