I have a simple window application with declared main window callback procedure:
WNDCLASSEXW wcx;
/* ... */
wcx.lpfnWndProc = MainWndProc;
and after the WinMain I declared LRESULT CALLBACK MainWndProc(HWND mainWindow, UINT msg, WPARAM wparam, LPARAM lparam) { /* ... */} and all is working ok, but I wonder is it possible to have this MainWndProc as a lambda inside WinMain ?
You can use a lambda, provided it has no captures then it has an implicit conversion to function pointer:
The problem really is how much you can usefully do in a lambda as a callback without captures. You can still resort to “globals”, in the same way you might with a regular function as the callback.