zig/example/hello_world/hello_libc.zig

16 lines
343 B
Zig
Raw Normal View History

const c = @cImport({
2017-10-02 09:05:08 +08:00
// See https://github.com/zig-lang/zig/issues/515
@cDefine("_NO_CRT_STDIO_INLINE", "1");
@cInclude("stdio.h");
@cInclude("string.h");
});
const msg = c"Hello, world!\n";
2016-01-26 14:21:13 +08:00
export fn main(argc: c_int, argv: &&u8) -> c_int {
if (c.printf(msg) != c_int(c.strlen(msg)))
return -1;
return 0;
}