Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type is incorrent for windows' version nanosleep #16410

Open
jiacai2050 opened this issue Jul 15, 2023 · 3 comments
Open

type is incorrent for windows' version nanosleep #16410

jiacai2050 opened this issue Jul 15, 2023 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@jiacai2050
Copy link
Contributor

Zig Version

0.11.0-dev.3971+6bc9c4f71

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() !void {
    std.os.nanosleep(1, 0);
}

Compile file above with

zig build-exe -target x86_64-windows test.zig 

Following error will be thrown

/Users/jiacai/.zig/zig-macos-aarch64-0.11.0-dev.3971+6bc9c4f71/lib/std/os.zig:5324:50: error: expected type 'c_long', found 'isize'
        .tv_nsec = math.cast(isize, nanoseconds) orelse math.maxInt(isize),
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jiacai/.zig/zig-macos-aarch64-0.11.0-dev.3971+6bc9c4f71/lib/std/os.zig:5324:50: note: signed 32-bit int cannot represent all possible signed 64-bit values
referenced by:
    main: test.zig:4:11
    callMain: /Users/jiacai/.zig/zig-macos-aarch64-0.11.0-dev.3971+6bc9c4f71/lib/std/start.zig:608:32
    remaining reference traces hidden; use '-freference-trace' to see all reference traces


Expected Behavior

No error

@jiacai2050 jiacai2050 added the bug Observed behavior contradicts documented or intended behavior label Jul 15, 2023
@jiacai2050
Copy link
Contributor Author

jiacai2050 commented Jul 15, 2023

It seems there exists a PR try fix this #14795, but closed without obvious reason...

After apply #14795, it still failed

$ zig build-exe -target x86_64-windows-gnu -lc test.zig 
error: lld-link: undefined symbol: nanosleep
    note: referenced by /Users/jiacai/.zig/zig-macos-aarch64-0.11.0-dev.3971+6bc9c4f71/lib/std/os.zig:5329
    note:               test.exe.obj:(os.nanosleep)

Does this means that nanosleep is not supported on windows?

jiacai2050 added a commit to jiacai2050/zigcli that referenced this issue Jul 15, 2023
@xdBronch
Copy link
Contributor

not that its a proper solution for this but look into std.time.sleep, it takes ns as input and seems to function correctly on windows.

@kassane
Copy link
Contributor

kassane commented Jul 15, 2023

It seems there exists a PR try fix this #14795, but closed without obvious reason...

Nanosleep requires winpthreads and Zig does not currently support it.

#10989 (comment)

@andrewrk andrewrk added the standard library This issue involves writing Zig code for the standard library. label Jul 22, 2023
@andrewrk andrewrk added this to the 0.14.0 milestone Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

4 participants