HandmadeHero/docs/Day 021.md

16 lines
1015 B
Markdown
Raw Normal View History

2023-09-26 14:26:35 -07:00
# Day 21
So I learned today the good reason why he doesn't use static variables; So that when he makes this library dynamically loaded we don't lose the state of the game on reload.
This day was extremely gratifying to get working.
I went the extra mile than what Casey did and allow for name mangled symbols (for both clang and msvc).
It took a few more steps than his solution but I get to keep the eronomics of namespaces.
After the linker finishes emitting, I use the build script to parse the .map file and extract the decorated symbols I need to load in the platform layer. Those are exported to a file called `handmade_engine.symbols` and then in the platform layer I load them up using an enum as the lookup table for the line the symbol will be in the file. From there its just loading up the symbol with GetProcAddress!
![img](https://files.catbox.moe/sdebtc.png)
![img](https://files.catbox.moe/ufkacl.png)
![img](https://files.catbox.moe/zr52au.png)
![img](https://files.catbox.moe/g3f1vv.png)