Hot Reload C
A simple SDL2 program to demonstrate how to hot reload C.
This program can be built on MacOS and Linux.
First you need to install
brew install sdl2
- Linux: Check your package manager, e.g. on Manjaro,
pacman -S sdl2
Then clone the code and build
$ git clone ... && cd ... $ make run # while the program is running, modify render.c and rebuild $ make build # and then the program will be hot reloaded 🚀
The main idea behind this is
Shared Library a.k.a
Dynamic Loaded Library.
We compile the render logic into a separate shared library and load it in main program dynamically via these apis:
So while the main program is running, we can rebuild our render library to hot load the main program.
dynamic linking for more details.