64 posts
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

Mārtiņš Možeiko
2357 posts / 2 projects
how does two "main()" work?
Edited by Mārtiņš Možeiko on

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

64 posts
how does two "main()" work?