Find me in the starry night

about / interests / blog / credits / links


October 8, 2025 - Modern C development!

I've been working on a toy programming language written in C for the last few days. C can be a very annoying language to work with but I really like Nic Barker's videos on modern C development. There's a lot of good ideas and research in them that's been kind of rekindling my interest in using it as a language!

One tidbit of information is that you can avoid using a build system by just including all of the source code in a single file. So instead of compiling multiple *.c files to *.o files and linking, you just compile a single main.c file that includes all others directly into a binary.

So my main.c file looks like this:


#include <yeah/src.inc>

int main() {
    ...
}
                

And then I have a file called yeah/src.inc that looks like this:


#pragma once

#include <yeah/array.c>
#include <yeah/code.c>
#include <yeah/error.c>
#include <yeah/instruction.c>
#include <yeah/io.c>
#include <yeah/lexer.c>
#include <yeah/log.c>
#include <yeah/machine.c>
#include <yeah/math.c>
#include <yeah/stack.c>
#include <yeah/value.c>
                

Apparently, code actually compiles faster this way as opposed to using a build system. The main con is that there's no easy caching of unchanged files this way. And dependency management using something like Conan is out of the question.

I'm going to have to switch over to using a build system - probably Meson - but until then I have nice fast compilations with a single shell command:


gcc --std=gnu11 -O0 -g -Wall -Werror -Wextra -Isrc \
    src/yeah/main.c -o yeah
                

And it takes 70ms (although I do have a MacBook Pro M4 max cause I'm a whore for expensive tech lol).