When using Zig’s build system for C/C++ projects, editors struggle to find include paths and provide proper code intelligence. compile_flagz solves this by automatically generating compile_flags.txt from your build.zig configuration. The Problem Recently I’ve been working on ROLLER, a decompilation project for the 1995 game, Fatal Racing (or Whiplash in NA). The game (known internally as Roller), is an early 3D game written in C with a bespoke engine. It also happens to be one of my favourite games from the 90s. I remember playing it a whole lot as a teenager with my best friend after we found it on a WAREZ CD. I’ve since fixed the error of my ways and secured a physical copy a few years ago. You can read more about it here. Zig provides a powerful build system, and it ships a C/C++ compiler using LLVM. It can make cross-compilation of projects a breeze, allowing you to build for just about any target you want. (Note: unfortunately it’s not currently possible to cross-compile SDL from Linux to MacOS.) However when working with said C/C++ code with Zig as your build system, your editor (or IDE) won’t be able to find the necessary include paths or libraries to make the developer experience seamless. Your editor needs some way to determine where your includes live so that it can provide rich code completion and error highlighting. Consider the following code from ROLLER: // File: roller.c // Without include paths, your editor won't know where to find the SDL_image header file. #include <SDL3_image/SDL_image.h> // ... int InitSDL() { // ... s_pWindowTexture = SDL_CreateTexture(s_pRenderer, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, 640, 400); SDL_SetTextureScaleMode(s_pWindowTexture, SDL_SCALEMODE_NEAREST); s_pDebugTexture = SDL_CreateTexture(s_pRenderer, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, 64, 64); SDL_SetTextureScaleMode(s_pDebugTexture, SDL_SCALEMODE_NEAREST); s_pRGBBuffer = malloc(640 * 400 * 3); s_pDebugBuffer = malloc(64 * 64 * 3); // This...
First seen: 2025-09-13 03:25
Last seen: 2025-09-13 06:32