| author | |
| committer | |
| log | 4bf149795acea088b349be89cb7992a6d413ad9f |
| tree | 00d02e37ccf13cf54d291b8e0d9be99e28379d94 |
| parent | a2e6ada1c681123c8674f61b91862b5377f1dda1 |
edge cases matter
See #5102 files changed, 10 insertions(+), 3 deletions(-)
example/hello_world/hello.zig+1-1| ... | @@ -1,5 +1,5 @@ | ... | @@ -1,5 +1,5 @@ |
| 1 | const io = @import("std").io; | 1 | const io = @import("std").io; |
| 2 | 2 | ||
| 3 | pub fn main() -> %void { | 3 | pub fn main() -> %void { |
| 4 | %%io.stdout.printf("Hello, world!\n"); | 4 | %return io.stdout.printf("Hello, world!\n"); |
| 5 | } | 5 | } |
example/hello_world/hello_libc.zig+9-2| ... | @@ -1,6 +1,13 @@ | ... | @@ -1,6 +1,13 @@ |
| 1 | const c = @cImport(@cInclude("stdio.h")); | 1 | const c = @cImport({ |
| 2 | @cInclude("stdio.h"); | ||
| 3 | @cInclude("string.h"); | ||
| 4 | }); | ||
| 5 | |||
| 6 | const msg = c"Hello, world!\n"; | ||
| 2 | 7 | ||
| 3 | export fn main(argc: c_int, argv: &&u8) -> c_int { | 8 | export fn main(argc: c_int, argv: &&u8) -> c_int { |
| 4 | _ = c.printf(c"Hello, world!\n"); | 9 | if (c.printf(msg) != c_int(c.strlen(msg))) |
| 10 | return -1; | ||
| 11 | |||
| 5 | return 0; | 12 | return 0; |
| 6 | } | 13 | } |