Search code examples
c++eventssdlstylus

Pointer to incomplete class type "SDL_SysWMmsg" is not allowed


I try to get the hwnd handler from SDL focus event

I cannot compile this part with visual studio 2019

it says pointer to incomplete class type "SDL_SysWMmsg" is not allowed around pMsg->

if (e.type == SDL_SYSWMEVENT)
{
    SDL_SysWMmsg* pMsg = e.syswm.msg;
                
    if (pMsg && pMsg->msg == WM_SETFOCUS)
    {
        ...
    }
    break;
}

Solution

  • You need to include that header. Currently the compiler only knows, that SDL_SysWMmsg is a struct, and it is perfectly fine, when used as a pointer to a structure, because every pointer is just an address to the memory in the same format for all types (read more). If you need to know the layout of the structure, then you need a definition of structure.