ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
32.09k stars 2.34k forks source link

Support `wasm32-emscripten` libc #20090

Open qdwang opened 1 month ago

qdwang commented 1 month ago

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

const jpegli = @cImport({
    @cInclude("stddef.h");
    @cInclude("stdio.h");
    @cInclude("jpeglib.h");
});

The jpeglib.h doesn't include stddef.h and stdio.h, so the types inside like size_t and FILE will cause errors: error: unknown type name X.

So I added @cInclude("stddef.h") and @cInclude("stdio.h"). The problem is: error: unknown type name 'FILE' still occurs.

When target is wasm32-freestanding, there is no problem at all. The issue only happens in wasm32-emscripten.

Expected Behavior

It should compile.

Vexu commented 1 month ago

Zig doesn't support libc for wasm32-emscripten.