diff --git a/examples/benchmarks/platform/host.zig b/examples/benchmarks/platform/host.zig index 33b9fdd740..857dc3b43d 100644 --- a/examples/benchmarks/platform/host.zig +++ b/examples/benchmarks/platform/host.zig @@ -150,7 +150,7 @@ pub export fn roc_fx_putInt(int: i64) i64 { return 0; } -export fn roc_fx_putLine(rocPath: str.RocStr) callconv(.C) void { +export fn roc_fx_putLine(rocPath: *str.RocStr) callconv(.C) void { const stdout = std.io.getStdOut().writer(); for (rocPath.asSlice()) |char| { diff --git a/examples/hello-world/c-platform/host.c b/examples/hello-world/c-platform/host.c index d685f605c1..a096367dd5 100644 --- a/examples/hello-world/c-platform/host.c +++ b/examples/hello-world/c-platform/host.c @@ -54,10 +54,12 @@ size_t roc_str_len(struct RocStr str) { } } -extern struct RocStr roc__mainForHost_1_exposed(); +extern void roc__mainForHost_1_exposed_generic(*RocStr); int main() { - struct RocStr str = roc__mainForHost_1_exposed(); + + struct RocStr str; + roc__mainForHost_1_exposed_generic(&str); // Determine str_len and the str_bytes pointer, // taking into account the small string optimization. diff --git a/examples/hello-world/rust-platform/src/lib.rs b/examples/hello-world/rust-platform/src/lib.rs index 5c90b91be8..7df8fe563c 100644 --- a/examples/hello-world/rust-platform/src/lib.rs +++ b/examples/hello-world/rust-platform/src/lib.rs @@ -6,8 +6,8 @@ use std::ffi::CStr; use std::os::raw::c_char; extern "C" { - #[link_name = "roc__mainForHost_1_exposed"] - fn roc_main() -> RocStr; + #[link_name = "roc__mainForHost_1_exposed_generic"] + fn roc_main(_: &mut RocStr); } #[no_mangle] @@ -56,7 +56,8 @@ pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut #[no_mangle] pub extern "C" fn rust_main() -> i32 { unsafe { - let roc_str = roc_main(); + let mut roc_str = RocStr::default(); + roc_main(&mut roc_str); let len = roc_str.len(); let str_bytes = roc_str.as_bytes().as_ptr() as *const libc::c_void; diff --git a/examples/hello-world/zig-platform/host.zig b/examples/hello-world/zig-platform/host.zig index d30eccfbfe..f20686dcb0 100644 --- a/examples/hello-world/zig-platform/host.zig +++ b/examples/hello-world/zig-platform/host.zig @@ -77,7 +77,7 @@ export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { const mem = std.mem; const Allocator = mem.Allocator; -extern fn roc__mainForHost_1_exposed() RocStr; +extern fn roc__mainForHost_1_exposed_generic(*RocStr) void; const Unit = extern struct {}; @@ -90,7 +90,8 @@ pub fn main() u8 { std.os.clock_gettime(std.os.CLOCK_REALTIME, &ts1) catch unreachable; // actually call roc to populate the callresult - var callresult = roc__mainForHost_1_exposed(); + var callresult = RocStr.empty(); + roc__mainForHost_1_exposed_generic(&callresult); // end time var ts2: std.os.timespec = undefined;