diff options
| author | Andrea Orru <andrea@orru.io> | 2018-08-06 01:43:19 -0400 |
|---|---|---|
| committer | Andrea Orru <andrea@orru.io> | 2018-08-06 01:43:19 -0400 |
| commit | d2f5e57b68da0b16e5789ca19045ccbcb4ecfa8d (patch) | |
| tree | e9fa3caec533a0d1e2b434868b2fde1f9240e5c8 /example | |
| parent | 06614b3fa09954464c2e2f32756cacedc178a282 (diff) | |
| parent | 63a23e848a62d5f167f8d5478de9766cb24aa6eb (diff) | |
| download | zig-d2f5e57b68da0b16e5789ca19045ccbcb4ecfa8d.tar.gz zig-d2f5e57b68da0b16e5789ca19045ccbcb4ecfa8d.zip | |
Merge branch 'master' into zen_stdlib
Diffstat (limited to 'example')
| -rw-r--r-- | example/cat/main.zig | 4 | ||||
| -rw-r--r-- | example/guess_number/main.zig | 2 | ||||
| -rw-r--r-- | example/hello_world/hello_libc.zig | 7 | ||||
| -rw-r--r-- | example/mix_o_files/base64.zig | 2 | ||||
| -rw-r--r-- | example/mix_o_files/build.zig | 6 | ||||
| -rw-r--r-- | example/shared_library/build.zig | 6 |
6 files changed, 11 insertions, 16 deletions
diff --git a/example/cat/main.zig b/example/cat/main.zig index de0d323bed..27690d2695 100644 --- a/example/cat/main.zig +++ b/example/cat/main.zig @@ -7,7 +7,7 @@ const allocator = std.debug.global_allocator; pub fn main() !void { var args_it = os.args(); - const exe = try unwrapArg(??args_it.next(allocator)); + const exe = try unwrapArg(args_it.next(allocator).?); var catted_anything = false; var stdout_file = try io.getStdOut(); @@ -41,7 +41,7 @@ fn usage(exe: []const u8) !void { return error.Invalid; } -fn cat_file(stdout: &os.File, file: &os.File) !void { +fn cat_file(stdout: *os.File, file: *os.File) !void { var buf: [1024 * 4]u8 = undefined; while (true) { diff --git a/example/guess_number/main.zig b/example/guess_number/main.zig index 7178c5274a..bed132b25c 100644 --- a/example/guess_number/main.zig +++ b/example/guess_number/main.zig @@ -23,7 +23,7 @@ pub fn main() !void { while (true) { try stdout.print("\nGuess a number between 1 and 100: "); - var line_buf : [20]u8 = undefined; + var line_buf: [20]u8 = undefined; const line_len = io.readLine(line_buf[0..]) catch |err| switch (err) { error.InputTooLong => { diff --git a/example/hello_world/hello_libc.zig b/example/hello_world/hello_libc.zig index 60123c6fd8..60a1f76871 100644 --- a/example/hello_world/hello_libc.zig +++ b/example/hello_world/hello_libc.zig @@ -1,5 +1,5 @@ const c = @cImport({ - // See https://github.com/zig-lang/zig/issues/515 + // See https://github.com/ziglang/zig/issues/515 @cDefine("_NO_CRT_STDIO_INLINE", "1"); @cInclude("stdio.h"); @cInclude("string.h"); @@ -7,9 +7,8 @@ const c = @cImport({ const msg = c"Hello, world!\n"; -export fn main(argc: c_int, argv: &&u8) c_int { - if (c.printf(msg) != c_int(c.strlen(msg))) - return -1; +export fn main(argc: c_int, argv: **u8) c_int { + if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1; return 0; } diff --git a/example/mix_o_files/base64.zig b/example/mix_o_files/base64.zig index e682a97055..7ded9824a0 100644 --- a/example/mix_o_files/base64.zig +++ b/example/mix_o_files/base64.zig @@ -1,6 +1,6 @@ const base64 = @import("std").base64; -export fn decode_base_64(dest_ptr: &u8, dest_len: usize, source_ptr: &const u8, source_len: usize) usize { +export fn decode_base_64(dest_ptr: [*]u8, dest_len: usize, source_ptr: [*]const u8, source_len: usize) usize { const src = source_ptr[0..source_len]; const dest = dest_ptr[0..dest_len]; const base64_decoder = base64.standard_decoder_unsafe; diff --git a/example/mix_o_files/build.zig b/example/mix_o_files/build.zig index 4380486867..a4e7fbbf8f 100644 --- a/example/mix_o_files/build.zig +++ b/example/mix_o_files/build.zig @@ -1,12 +1,10 @@ const Builder = @import("std").build.Builder; -pub fn build(b: &Builder) void { +pub fn build(b: *Builder) void { const obj = b.addObject("base64", "base64.zig"); const exe = b.addCExecutable("test"); - exe.addCompileFlags([][]const u8 { - "-std=c99", - }); + exe.addCompileFlags([][]const u8{"-std=c99"}); exe.addSourceFile("test.c"); exe.addObject(obj); diff --git a/example/shared_library/build.zig b/example/shared_library/build.zig index 2b5a178b35..05648cf9eb 100644 --- a/example/shared_library/build.zig +++ b/example/shared_library/build.zig @@ -1,12 +1,10 @@ const Builder = @import("std").build.Builder; -pub fn build(b: &Builder) void { +pub fn build(b: *Builder) void { const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0)); const exe = b.addCExecutable("test"); - exe.addCompileFlags([][]const u8 { - "-std=c99", - }); + exe.addCompileFlags([][]const u8{"-std=c99"}); exe.addSourceFile("test.c"); exe.linkLibrary(lib); |
