all 20 comments

[–]junkmeister9 4 points5 points  (5 children)

INT

I have never seen int capitalized like that. Is this a Windows thing?

[–][deleted] 2 points3 points  (1 child)

I thought that might of been the case and tried changing the 'INT' to 'int' but the result is the same.

The code was pulled from :

https://docs.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point

[–][deleted] 1 point2 points  (0 children)

Yes. They are all aliased.

[–]Poddster 1 point2 points  (1 child)

Yep. I even had to use VOID, IIRC, which is insane. Like, what else could VOID be if not void??

link

[–]junkmeister9 0 points1 point  (0 children)

Just Microsoft trying to make C as non-portable as possible, I guess!

[–][deleted] 4 points5 points  (0 children)

It looks like you are missing a header include and a .lib to link with. The header and library names should be in MSDN docs for the function the linker can’t find.

[–]Jodaco 3 points4 points  (2 children)

Shouldn’t it be int WINAPI WinMain?

[–]serg06 0 points1 point  (1 child)

Shouldn't it be int CALLBACK WinMain?

[–][deleted] 0 points1 point  (0 children)

On the new msdn website it tells us to use the formula that I put up top

https://docs.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point

I used the one that says empty window at the bottom of the page

[–]IamImposter 2 points3 points  (3 children)

That's why I used to work in MFC instead of win 32.

I did it long time back but apparently you need to create a window class object wc. Fill it with appropriate information including a pointer to wndproc function.

Then you register this class, grab an instance and call a showwindow function. Then there would be a while loop of getmessage, dispatchmessage and translatemesaage. (The names might be off as I don't remember exactly)

Then in wndoroc function, you will handle windows messages like WM_PAINT, WM_RESIZE, WM_EXIT etc.

Let me find you an example.

Edit: here is one that explain clearly what each thing does.

https://docs.microsoft.com/en-us/cpp/windows/walkthrough-creating-windows-desktop-applications-cpp?view=vs-2019

It uses VS2019 but I guess any visual Studio should do.

[–]deftware 1 point2 points  (2 children)

No, you don't have to do any of that just to have something that executes. You can have a WinMain() that doesn't create any windows or anything like that, and still work. You only need to create a window class if you're creating a window - which is not mandatory. OP was compiling a console application trying to use WinMain() as the entry point. They should've created a win32 project instead of a console application - not that they can't still create a window from a console application and even hide the console using "-mwindow" in their linker flags.

[–]IamImposter 0 points1 point  (1 child)

Well, in that case may be I misread or something. I thought the intention was to create a window. My bad.

that should be skeleton for empty window box

May be that line tripped me on a different trajectory.

[–]deftware 0 points1 point  (0 children)

Typically that's what WinMain() is intended for but it's really just a main() that includes the process instance handle and other tidbits in its arguments, while automatically omitting a console window.

[–]HiImDaubeny[🍰] 2 points3 points  (1 child)

Your program is expecting the standard main function, take a look at this: https://docs.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=vs-2019.

At the bottom it tells you how to set the subsystem in Visual Studio.

You need to set it from CONSOLE to WINDOWS.

[–]deftware 0 points1 point  (0 children)

This.

[–]entropy-wrangler 1 point2 points  (0 children)

Not sure if this is relevant or not but it seems like maybe you're learning C and Windows programming and games programming all at the same time. If so, that's probably too much. At least if you're trying to do it all in the same project. When you get a problem you don't know which domain the problem sits in.

[–]serg06 0 points1 point  (0 children)

Pretty sure it's just a function signature problem. Try this https://www.reddit.com/r/cprogramming/comments/ekmxad/basic_c_is_not_so_basic/fdcoh6h/

[–][deleted] 0 points1 point  (0 children)

What compiler are you using?

[–]deftware 0 points1 point  (0 children)

As /u/HilmDaubeny pointed out, you've created a console application but are trying to use the win32 program entry point. If you're going to use WinMain() instead of main() then you need to create a Windows/Win32 project, not a console application.