不允许指向不完整 class 类型 "SDL_SysWMmsg" 的指针

Pointer to incomplete class type "SDL_SysWMmsg" is not allowed

我尝试从 SDL 焦点事件中获取 hwnd 处理程序

我无法用 visual studio 2019

编译这部分

它说 指向不完整 class 类型“SDL_SysWMmsg”的指针在 pMsg-> 附近是不允许的

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

您需要包括 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)。如果你需要知道结构的布局,那么你需要结构的定义。