how does two "main()" work?

I'm back at taking a look at the code, so apologize if this is clearly explained somewhere. I noticed two things:

in win32_handmade.cpp we have

WinMainCRTStartup()

which I assume is the real first call for win32

but in simple_preprocessor.cpp we have a main() as well.

Tried to find the episode where this is shown but didn't find "preprocessor" in the guide.

So how does that work?

cheers

There can be only one "main" entry point in executable.

simple_preprocessor.cpp is compiled to separate .exe file independently of win32_handmade.cpp file. Check the build.bat file to see how it is compiled.

If you are not aware - you can search in episode guide. Here's the simple_preprocessor.cpp search with finding exact episodes when it was created: https://guide.handmadehero.org/#simple_preprocessor.cpp


Edited by Mārtiņš Možeiko on

Thx Martins, dumb me I searched CTRL-F


Replying to mmozeiko (#26242)