file 1: "/home/ityonemo/helper.zig"
pub fn helper() u8 {
return 190;
}
file 2: "/home/ityonemo/test.zig"
const std = @import("std");
const helper = @import("/home/ityonemo/helper.zig");
pub fn main() !void {
// If this program is run without stdout attached, exit with an error.
const stdout_file = try std.io.getStdOut();
// If this program encounters pipe failure when printing to stdout, exit
// with an error.
var out_string = "Hello, world!\n";
out_string[0] = helper.helper();
try stdout_file.write(out_string);
}
command:
/path/to/zig/zig build-exe test.zig -dynamic --disable-gen-h --override-lib-dir /path/to/zig/lib/zig
reported compiler error:
/home/ityonemo/test.zig:2:16: error: unable to find '/home/ityonemo/helper.zig'
when you change the helper to
const helper = @import("helper.zig")
program compiles, and works as expected, (stdout: mello world!)
file 1: "/home/ityonemo/helper.zig"
file 2: "/home/ityonemo/test.zig"
command:
/path/to/zig/zig build-exe test.zig -dynamic --disable-gen-h --override-lib-dir /path/to/zig/lib/zigreported compiler error:
/home/ityonemo/test.zig:2:16: error: unable to find '/home/ityonemo/helper.zig'when you change the helper to
const helper = @import("helper.zig")program compiles, and works as expected, (stdout:
mello world!)