3 ms·
I think you misunderstood my question. I am not (in this question) interested in C or C interopability of zig, but how to structure larger zig project (how zig
by andi999 6y ago
I think you misunderstood my question. I am not (in this question) interested in C or C interopability of zig, but how to structure larger zig project (how zig thinks this should be handled)
- flohofwoe 6y agoYeah, I realized that after I hit send :) For regular Zig source files, you just import them into other Zig source files, up to the "main file". Such imports are wrapped into a module struct (imported modules are just regular structs). The Zig build system takes care of efficiently compiling all this with proper incremental build support (one can explore the zig-cache subdirectory which is maintained by the zig compiler for details). For example, these are the imports in a top-level file: https://github.com/floooh/pacman.zig/blob/ed42fad79c3e9b4432ea7e1ca97d56cba48c0282/src/pacman.zig#L1-L7 https://github.com/floooh/pacman.zig/blob/ed42fad79c3e9b4432... The sokol.zig file groups other modules under a common namespace: https://github.com/floooh/pacman.zig/blob/main/src/sokol/sokol.zig https://github.com/floooh/pacman.zig/blob/main/src/sokol/sok... ...which in turn imports "leaf modules" like this: https://github.com/floooh/pacman.zig/blob/main/src/sokol/audio.zig https://github.com/floooh/pacman.zig/blob/main/src/sokol/aud... ...it's one of the most straightforward module systems I've seen yet in any language.