Handmade Hero»Forums»Game
Day 11/12 visual studio 2022 not recognizing internal void?

I'm trying to load the code for day 11 into visual studio 2022. I've already built in sln and I keep getting a "handmade.h(30,10): error C2144: syntax error: 'void' should be preceded by ';'" which seems to be being caused by the internal in front of void. If I take away the internal I get all sorts of other errors. Has anyone seen this before, or does anyone know what to do about this?

Mārtiņš Možeiko
2406 posts / 2 projects
Day 11/12 visual studio 2022 not recognizing internal void?
Edited by Mārtiņš Možeiko on

You mean you are creating new VS prject and adding all the files there? You must be careful to make sure only win32_handmade.cpp file is built. Because HH codebase is supposed to be built as "unity" build - you only compile only one file that includes rest of .cpp files automatically. So you need to either remove handmade.cpp file from project or set in its properties to be excluded from build. And leave only win32_handmade.cpp file that should be built.

Day 11/12 visual studio 2022 not recognizing internal void?
Edited by SnultanSnandwich on

Thank you that worked perfectly. Do you mind explaining/pointing to why exactly including the other files in the project causes this? I understand the concept of unity builds just not exactly why it creates such a problem for visual studio, or why visual studio doesn't seem to believe internal voids are a thing.

edit: I now understand why internal wasn't treated properly. I forgot about the #define at the start of win32_handmade.cpp and thought it was a default part of c like it appears to be in c#.

Simon Anciaux
1241 posts
Day 11/12 visual studio 2022 not recognizing internal void?
Replying to SnultanSnandwich (#26811)

When you include files in a Visual Studio project, visual studio will compile every .c and .cpp file separately (each one is a translation unit), and than links all the resulting .obj to create the executable. Since our files don't #include the necessary headers, they won't compile properly. So if you include other files in the project you need to exclude them from being compiled.

Day 11/12 visual studio 2022 not recognizing internal void?

I see. Thats very helpful thank you.