Handmade Hero»Forums»Code
19 posts
Help with Day 015 - File IO - static visibility issue with Visual Studio 2019
Edited by echu on
I'm using Visual Studio 2019 to try and compile the code, but I ran into C2129 static function 'void DEBUGPlatformFreeFileMemory(void *)' declared but not defined in line 100 of handmade.cpp. Line 100 doesn't exist, since the last line of code in that file is line 99. The underlying issue appears that Visual Studio thinks the pieces of code are in different translation units. Visual Studio even allows me to jump to the function declaration in win32_handmade.cpp by crtl+clicking from handmade.h. But GameUpdateAndRender is in a similar situation, and no strange visibility issues occur!

Please see the attached images here .

Removing the internal keyword from handmade.h on those 3 functions appear to allow the code to work with parity with the command-line build and tutorial, but I'm scared to diverge too much from what Casey has with these quick "hacks" for sake of unrecoverable incompatibilities down the line. Still, the question remains on why Visual Studio doesn't see these functions in the same translation unit! VS seems to want to add the macro internal to a "hint file". I've never seen that before, and it seems like some strange visibility issues around that are happening.
Marc Costa
65 posts
Help with Day 015 - File IO - static visibility issue with Visual Studio 2019
Casey's build model differs from VS' default one. If you want to use VS to follow along, you'll need to change how it builds the source code. I believe this thread describes the changes you'll need: https://hero.handmade.network/for...using_vs_instead_of_a_text_editor
Mārtiņš Možeiko
2559 posts / 2 projects
Help with Day 015 - File IO - static visibility issue with Visual Studio 2019
Also Casey is using VS 2013. Newer VS version have compiler with different set of warnings / errors. You will need to modify code to work around compiler errors or adjust compiler arguments to ignore warnings.
19 posts
Help with Day 015 - File IO - static visibility issue with Visual Studio 2019
Edited by echu on
Thanks, that was helpful. I'm thinkering with Visual Studio and got it semi-working with all switches (day 16) with the exception of the static visibility. I'll probably fall back to simple-command line builds, since they always work.