Zig: Error: container 'std.debug' has no member called 'print'

Created on 24 Jun 2020  路  2Comments  路  Source: ziglang/zig

Hello,

Why "Hello, World" won't works in real!

I copy source-code from this page:
https://ziglang.org/documentation/master/#toc-Hello-World

[max@base build]$ zig version
0.6.0
[max@base build]$ cat h.zig
const print = @import("std").debug.print;

pub fn main() void {
    print("Hello, world!\n", .{});
}
[max@base build]$ zig build-exe h.zig
./h.zig:1:35: error: container 'std.debug' has no member called 'print'
const print = @import("std").debug.print;
                                  ^
./h.zig:4:5: note: referenced here
    print("Hello, world!\n", .{});
    ^

https://github.com/ziglang/zig/blob/c3e0224792510e69763dbc6ba68794f9134925f2/lib/std/debug.zig#L61


[max@base build]$ cat h.zig
const print = @import("std").debug.warn;

pub fn main() void {
    print("Hello, world!\n", .{});
}

https://github.com/ziglang/zig/blob/c3e0224792510e69763dbc6ba68794f9134925f2/lib/std/debug.zig#L57

[max@base build]$ zig build-exe h.zig
[max@base build]$ ./h
Hello, world!

Finally, It's one problem in document or a bug in compiler?

Regards,
Max Base

Most helpful comment

Hello Max,

It looks like you're using zig version 0.6.0 but referring to the documentation for the master branch. You can find the docs for the 0.6.0 release here: https://ziglang.org/documentation/0.6.0/. On the master branch std.debug.warn has been deprecated in favor of std.debug.print as you seem to have realized.

Cheers,
Isaac Freund

All 2 comments

Hello Max,

It looks like you're using zig version 0.6.0 but referring to the documentation for the master branch. You can find the docs for the 0.6.0 release here: https://ziglang.org/documentation/0.6.0/. On the master branch std.debug.warn has been deprecated in favor of std.debug.print as you seem to have realized.

Cheers,
Isaac Freund

Thanks you, and sorry for my mistake. :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jorangreef picture jorangreef  路  3Comments

andrewrk picture andrewrk  路  3Comments

andrewrk picture andrewrk  路  3Comments

bheads picture bheads  路  3Comments

andrewrk picture andrewrk  路  3Comments