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

Printing a File struct fails on Linux #2584

Closed
shritesh opened this issue May 29, 2019 · 2 comments
Closed

Printing a File struct fails on Linux #2584

shritesh opened this issue May 29, 2019 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@shritesh
Copy link
Contributor

shritesh commented May 29, 2019

This tries to compile windows specific functions and fails with compile errors.

const std = @import("std");

pub fn main() !void {
    var file = try std.fs.cwd().openFile("hello.txt", .{});
    defer file.close();

    std.debug.warn("{}\n", .{file});
}

Errors

/home/shritesh/zig/build/lib/zig/std/fs/file.zig:60:27: error: expected type 'i32', found '*c_void'
        return openHandle(handle);
                          ^
/home/shritesh/zig/build/lib/zig/std/fs/file.zig:102:27: error: expected type 'i32', found '*c_void'
        return openHandle(handle);
                          ^
/home/shritesh/zig/build/lib/zig/std/fs/file.zig:137:27: error: expected type 'i32', found '*c_void'
        return openHandle(handle);
                          ^
/home/shritesh/zig/build/lib/zig/std/fs/file.zig:160:18: error: container 'std.os' has no member called 'accessW'
        return os.accessW(path, os.F_OK);
                 ^
/home/shritesh/zig/build/lib/zig/std/os/windows.zig:69:28: error: dependency on dynamic library 'kernel32' requires enabling Position Independent Code
    const result = kernel32.CreateFileW(file_path_w, desired_access, share_mode, lpSecurityAttributes, creation_disposition, flags_and_attrs, hTemplateFile);
                           ^
/home/shritesh/zig/build/lib/zig/std/os/windows.zig:69:28: note: fixed by `--library kernel32` or `--enable-pic`
    const result = kernel32.CreateFileW(file_path_w, desired_access, share_mode, lpSecurityAttributes, creation_disposition, flags_and_attrs, hTemplateFile);
                           ^
@andrewrk andrewrk added this to the 0.5.0 milestone May 29, 2019
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label May 29, 2019
@andrewrk
Copy link
Member

I believe this will be solved by #2174

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. stage1 The process of building from source via WebAssembly and the C backend. labels Aug 27, 2019
@andrewrk
Copy link
Member

What's going on here is that @typeInfo forces all member functions of a struct to be generated, even ones that are otherwise never referenced. Instead of this, indeed, lazy values should be used to avoid this. Now that #2174 is implemented, the framework to fix this issue is in place.

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 enhancement Solving this issue will likely involve adding new logic or components to the codebase. stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

2 participants