| ... | ... | @@ -1,26 +1,29 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | const builtin = @import("builtin"); |
| 2 | 3 | |
| 3 | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | | cases.addTest( |
| 5 | | "implicit dependency on libc", |
| 6 | | \\extern "c" fn exit(u8) void; |
| 7 | | \\export fn entry() void { |
| 8 | | \\ exit(0); |
| 9 | | \\} |
| 10 | | , |
| 11 | | ".tmp_source.zig:3:5: error: dependency on library c must be explicitly specified in the build command", |
| 12 | | ); |
| 5 | if (builtin.os == builtin.Os.linux) { |
| 6 | cases.addTest( |
| 7 | "implicit dependency on libc", |
| 8 | \\extern "c" fn exit(u8) void; |
| 9 | \\export fn entry() void { |
| 10 | \\ exit(0); |
| 11 | \\} |
| 12 | , |
| 13 | ".tmp_source.zig:3:5: error: dependency on library c must be explicitly specified in the build command", |
| 14 | ); |
| 13 | 15 | |
| 14 | | cases.addTest( |
| 15 | | "libc headers note", |
| 16 | | \\const c = @cImport(@cInclude("stdio.h")); |
| 17 | | \\export fn entry() void { |
| 18 | | \\ c.printf("hello, world!\n"); |
| 19 | | \\} |
| 20 | | , |
| 21 | | ".tmp_source.zig:1:11: error: C import failed", |
| 22 | | ".tmp_source.zig:1:11: note: libc headers not available; compilation does not link against libc", |
| 23 | | ); |
| 16 | cases.addTest( |
| 17 | "libc headers note", |
| 18 | \\const c = @cImport(@cInclude("stdio.h")); |
| 19 | \\export fn entry() void { |
| 20 | \\ _ = c.printf(c"hello, world!\n"); |
| 21 | \\} |
| 22 | , |
| 23 | ".tmp_source.zig:1:11: error: C import failed", |
| 24 | ".tmp_source.zig:1:11: note: libc headers not available; compilation does not link against libc", |
| 25 | ); |
| 26 | } |
| 24 | 27 | |
| 25 | 28 | cases.addTest( |
| 26 | 29 | "comptime vector overflow shows the index", |