Handmade Hero»Forums»Code
Marsvin
2 posts
Day 22: Live code editing, source files locked
Hey all,

I managed to follow pretty much everything Cory demonstrated in the live code editing videos, but ran into a strange problem. When I run my win32_handmade.exe the handmade.cpp file gets locked (can't write to it.) Windows says "This file is open in win32_handmade.exe" (this is not related to the debugger, happens without the debugger too.)

I'm not sure why running the exe would lock the cpp source file. I double checked, there's no mention of handmade.cpp anywhere in the source (although even if
1
#include "handmade.cpp"
was still there, I wouldn't expect that to lock the file.)

As soon as I exit the exe the file is writable again.

Any thoughts would be greatly appreciated.
Mārtiņš Možeiko
2559 posts / 2 projects
Day 22: Live code editing, source files locked
I think at one point in GameUpdateAndRender fucntion Casey was reading (for debugging purposes) handmade.cpp file with DEBUGPlatformReadEntireFile function. "handmade.cpp" filename is passed to it as __FILE__ preprocessor macro.

But there is something a wrong if file is left locked. Check if you implemented DEBUGPlatformReadEntireFile function correctly.

Currently in latest day source this debug code is removed.
Marsvin
2 posts
Day 22: Live code editing, source files locked
Ah good call, I completely forgot about the readfile functions. It was referring to __FILE__ in handmade.cpp and I wasn't properly closing the file handle in ReadEntireFile. Thanks!