revert hello world examples. macos tests passing

This commit is contained in:
Andrew Kelley 2019-05-27 15:48:31 -04:00
parent db0a5e7516
commit 5de07ab721
2 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,9 @@
const std = @import("std");
pub fn main() void {
std.debug.warn("Hello, world!\n");
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.
try stdout_file.write("Hello, world!\n");
}

View File

@ -2,9 +2,12 @@ const c = @cImport({
// See https://github.com/ziglang/zig/issues/515
@cDefine("_NO_CRT_STDIO_INLINE", "1");
@cInclude("stdio.h");
@cInclude("string.h");
});
export fn main(argc: c_int, argv: [*]?[*]u8) c_int {
_ = c.fprintf(c.stderr, c"Hello, world!\n");
const msg = c"Hello, world!\n";
export fn main(argc: c_int, argv: **u8) c_int {
if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1;
return 0;
}