ousttrue/zig_uv
libuv zig build and uvbook
zig-0.13.0
error: lld-link: undefined symbol: __declspec(dllimport) _CrtSetReportHook
#if debug
add link to ucrtbased
master required
v1.48.0
has CONTAINING_RECORD issue.
> zig fetch --save=libuv git+https://github.com/libuv/libuv.git
patch for src/win/req-inl.h
INLINE static uv_req_t* uv__overlapped_to_req(OVERLAPPED* overlapped) {
// cause illegal instruction
// return CONTAINING_RECORD(overlapped, uv_req_t, u.io.overlapped);
return (uv_req_t*)((char*)overlapped - offsetof(uv_req_t, u.io.overlapped));
}
same https://github.com/libuv/libuv/pull/4254
merged 2024/08/06
pub const struct_uv_stream_s = extern struct {
read_cb: uv_read_cb = @import("std").mem.zeroes(uv_read_cb),
};
// 👆👇
pub const uv_read_cb = ?*const fn ([*c]uv_stream_t, isize, [*c]const uv_buf_t) callconv(.C) void;
// workaround
pub const uv_read_cb = ?*const fn (*anyopaque, isize, [*c]const uv_buf_t) callconv(.C) void;
> zig build -l
install (default) Copy build artifacts to prefix path
uninstall Remove build artifacts from prefix path
c_helloworld Build & run c_helloworld
zig_helloworld Build & run zig_helloworld
> zig build c-helloworld
name | c-win32 | zig |
---|---|---|
helloworld | o | o |
idle-basic | o | o |
name | c-win32 | zig |
---|---|---|
uvcat | o | o translated |
uvtee | o | o translated |
onchange | o | o |
name | c-win32 | zig |
---|---|---|
tcp-echo-server | o | o translated, TODO: client |
udp-dhcp | o | o translated |
dns | o | o TODO: not work |
interfaces | o | x @cimport error |
name | c-win32 | zig |
---|---|---|
thread-create | c | o |
locks | uv_barrier_wait | |
queue-work | <unistd.h> |
|
queue-cancel | <unistd.h> |
|
progress | <unistd.h> |
name | c-win32 | zig |
---|---|---|
spawn | o | o translated |
detach | o | |
signal | <unistd.h> |
|
proc-streams | o | |
cgi | o | and cgi/tick |
pipe-echo-server | o | |
multi-echo-server | o |
name | c-win32 | zig |
---|---|---|
uvstop | o | x |
name | c-win32 | zig |
---|---|---|
ref-timer | o | |
idle-compute | o | |
uvwget | <curl.h> |
|
plugin | o | and plugin/hello.c |
tty | o | |
tty-gravity | o | o translated |