+ 1

I am having an error on making window API on the function windowprocedure, how to solve this error?

I am using visual studio code 2019 This is the error description : 1). C4715 'Windowprocedure': not all control paths return a value API D:\cp\creative code\vs2019\API\API.cpp 57 2). LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) API D:\cp\creative code\vs2019\API\MSVCRTD.lib(exe_main.obj) 1 the code name is "API.cpp" in my profile you can check there as there is no option of adding code i am seeing here.

18th May 2020, 7:39 AM
Abhishek Dimri
Abhishek Dimri - avatar
3 Réponses
+ 1
I'm assuming you posted this on a pc. You can just copy paste the url from the playground to add your code. For the 1st problem you can just add a return 0 to the end of the function to make the compiler happy. The 2nd problem is that you probably didn't select the windows subsystem. Right click your solution name -> properties -> Linker -> System and then change SubSystem to Windows. Also you mistyped your class name in CreateWindowW which will prevent the window from being created.
18th May 2020, 9:06 AM
Dennis
Dennis - avatar
+ 1
LRESULT is just an integer, I believe 64 bit on a 64 bit system and 32 bit on a 32 bit system. The actual return value depends on the message. 0 usually means success. For example WM_CREATE should return 0 if the creation should succeed. If you placed return -1 inside the WM_CREATE case for example it would immediately destroy the window. https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-create Similarly for WM_DESTROY it should always return 0 https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-destroy Btw, CALLBACK is just a calling convention ( stdcall ), not the return type. https://en.wikipedia.org/wiki/X86_calling_conventions
18th May 2020, 11:01 AM
Dennis
Dennis - avatar
0
Dennis But the return type of the function is LRESULT CALLBACK will it still work with return 0?
18th May 2020, 10:54 AM
Abhishek Dimri
Abhishek Dimri - avatar