Skip to content

Instantly share code, notes, and snippets.

@bketelsen
Last active April 16, 2019 13:41
Show Gist options
  • Save bketelsen/ad78123b34b08cb740a9e285bf783e19 to your computer and use it in GitHub Desktop.
Save bketelsen/ad78123b34b08cb740a9e285bf783e19 to your computer and use it in GitHub Desktop.
export const cstring = packed struct {
ptr: [*c]u8,
len: usize,
fn init(slice: []const u8) cstring {
return cstring{
.ptr = slice.ptr,
.len = slice.len
};
}
};
export fn hello() cstring {
var h = "<div>Hello Brian</div>";
return cstring.init(h);
}
@bketelsen
Copy link
Author

cd src && zig build-exe main.zig --release-fast -target wasm32-freestanding-none
/home/bketelsen/projects/zig/zig-wasm-test/src/main.zig:19:23: error: expected type '[]u8', found '[22]u8'
  return cstring.init(h);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment