diff --git a/test/standalone/simple/hello_world/hello_libc.zig b/test/standalone/simple/hello_world/hello_libc.zig index 992afd736e76f7e52bb71c3eb482f98a0526a2a9..994ca31b8e23a9b8011ebe53c51f7b4f886b2fce 100644 --- a/test/standalone/simple/hello_world/hello_libc.zig +++ b/test/standalone/simple/hello_world/hello_libc.zig @@ -1,15 +1,11 @@ -const c = @cImport({ - // See https://github.com/ziglang/zig/issues/515 - @cDefine("_NO_CRT_STDIO_INLINE", "1"); - @cInclude("stdio.h"); - @cInclude("string.h"); -}); +extern fn printf(format: [*:0]const u8, ...) c_int; +extern fn strlen(str: [*:0]const u8) usize; const msg = "Hello, world!\n"; pub export fn main(argc: c_int, argv: **u8) c_int { _ = argv; _ = argc; - if (c.printf(msg) != @as(c_int, @intCast(c.strlen(msg)))) return -1; + if (printf(msg) != @as(c_int, @intCast(strlen(msg)))) return -1; return 0; } diff --git a/test/standalone/static_c_lib/foo.zig b/test/standalone/static_c_lib/foo.zig index da0287540871349cd777df35293fb01755e50b92..2ff5fadb95df1ae4177f3408df89d7f8e5c52e1e 100644 --- a/test/standalone/static_c_lib/foo.zig +++ b/test/standalone/static_c_lib/foo.zig @@ -1,12 +1,14 @@ const std = @import("std"); const expect = std.testing.expect; -const c = @cImport(@cInclude("foo.h")); + +extern fn add(a: u32, b: u32) u32; +extern var foo: u32; test "C add" { - const result = c.add(1, 2); + const result = add(1, 2); try expect(result == 3); } test "C extern variable" { - try expect(c.foo == 12345); + try expect(foo == 12345); }