Handmade Hero»Forums»Code
Bill
1 posts
Day 4 Unresolved reference
I've started from the beginning in VS, and have hit a wall in day 4 at around 27 minutes, just before Casey begins the pixel loop.

pastebin

"error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup"

in

"win32_handmade\win32_handmade\MSVCRTD.lib(crtexe.obj)"

The code built and ran fine on previous days. I've tried everything in the "avoiding c/c++ runtime" thread, and the "using VS instead of text editor" thread doesn't seem to be relevant. I kinda glazed through his setting up the emacs project since I'm using VS, and I haven't been using the command line so far so maybe I'm missing something there? I'd prefer to not have to go and set all that up if it can be helped.
Mārtiņš Možeiko
2566 posts / 2 projects
Day 4 Unresolved reference
Your main function cannot be arbitrary called "Win32WinMain".
It must be called WinMain or main depending whether you are using subsystem:windows or subsystem:console argument.

If you are linking without C/C++ runtime with "-nodefaultlib" linker argument, then your entry point must be called mainCRTStartup or WinMainCRTStartup. And it bust be void without any arguments any CALLBACK.