gpt4 book ai didi

SDL SDL_syswm.h fails to compile on windows(SDL SDL_syswm.h无法在Windows上编译)

转载 作者:bug小助手 更新时间:2023-10-25 23:00:23 24 4
gpt4 key购买 nike



I'm attempting to get some platform specific information from the struct SDL_SysWMinfo.

我正在尝试从结构SDL_SysWMInfo获取一些特定于平台的信息。


A minimal example that demonstrates the problem:

演示该问题的最小示例:


#include <SDL.h>
#include <SDL2/SDL_syswm.h>

void* getWindowHandle(SDL_Window* window)
{
SDL_SysWMinfo wmi{};
SDL_VERSION(&wmi.version);

if (!SDL_GetWindowWMInfo(window, &wmi)) return nullptr;

return wmi.info.win.window;
}

int test()
{
if (SDL_Init(SDL_INIT_VIDEO) != 0) return 1;

SDL_Window* window = SDL_CreateWindow("Test", 50, 50, 1024, 768, 0);

if (window == nullptr) return 1;

void* windowHandle = getWindowHandle(window);

SDL_DestroyWindow(window);
SDL_Quit();
}

I get these compile errors:

我得到以下编译错误:


C:\Users\Jarrett\.conan\data\sdl\2.28.2\_\_\package\aaaec587efc9384b1cddee85ec81c25825cb201f\include\SDL2/SDL_syswm.h(165,18): error C3646: 'hwnd': unknown override specifier (compiling source file C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\src\Test.cpp) [C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\cmake-build-relwithdebug\ice_engine\ice_engine.vcxproj]
C:\Users\Jarrett\.conan\data\sdl\2.28.2\_\_\package\aaaec587efc9384b1cddee85ec81c25825cb201f\include\SDL2/SDL_syswm.h(166,18): error C3646: 'msg': unknown override specifier (compiling source file C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\src\Test.cpp) [C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\cmake-build-relwithdebug\ice_engine\ice_engine.vcxproj]
C:\Users\Jarrett\.conan\data\sdl\2.28.2\_\_\package\aaaec587efc9384b1cddee85ec81c25825cb201f\include\SDL2/SDL_syswm.h(167,20): error C3646: 'wParam': unknown override specifier (compiling source file C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\src\Test.cpp) [C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\cmake-build-relwithdebug\ice_engine\ice_engine.vcxproj]
C:\Users\Jarrett\.conan\data\sdl\2.28.2\_\_\package\aaaec587efc9384b1cddee85ec81c25825cb201f\include\SDL2/SDL_syswm.h(168,20): error C3646: 'lParam': unknown override specifier (compiling source file C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\src\Test.cpp) [C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\cmake-build-relwithdebug\ice_engine\ice_engine.vcxproj]
C:\Users\Jarrett\.conan\data\sdl\2.28.2\_\_\package\aaaec587efc9384b1cddee85ec81c25825cb201f\include\SDL2/SDL_syswm.h(235,18): error C3646: 'window': unknown override specifier (compiling source file C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\src\Test.cpp) [C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\cmake-build-relwithdebug\ice_engine\ice_engine.vcxproj]
C:\Users\Jarrett\.conan\data\sdl\2.28.2\_\_\package\aaaec587efc9384b1cddee85ec81c25825cb201f\include\SDL2/SDL_syswm.h(236,17): error C3646: 'hdc': unknown override specifier (compiling source file C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\src\Test.cpp) [C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\cmake-build-relwithdebug\ice_engine\ice_engine.vcxproj]
C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\src\Test.cpp(11,25): error C2039: 'window': is not a member of 'SDL_SysWMinfo::<unnamed-type-info>::<unnamed-type-win>' [C\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\cmake-build-relwithdebug\ice_engine\ice_engine.vcxproj]

I can't figure out why I'm seeing this. Including the windows header (i.e. #include <windows.h>) doesn't seem to help.

我不明白为什么我会看到这个。包括窗口标题(即#INCLUDE )似乎没有什么帮助。


I'm compiling on windows 10 64 bit, using Visual Studio build tools 2022.

我正在使用Visual Studio构建工具2022在Windows 10 64位上进行编译。


Would anyone have any idea what I'm doing wrong here?

有人知道我做错了什么吗?


Edit

编辑


Here is the compile command:

以下是编译命令:


C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\CL.exe /c /IC:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\include /IC:\Users\Jarrett\projects\icebreakersentertainment\dark_hor
izon\ice_engine\include\scripting\angel_script\debugger /IC:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\include\scripting\angel_script\scriptarray /IC:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\include\
scripting\angel_script\scriptbuilder /IC:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\include\scripting\angel_script\scriptdictionary /IC:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\include\scripting\ange
l_script\scripthandle /IC:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\include\scripting\angel_script\scripthelper /IC:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\include\scripting\angel_script\scriptstds
tring /Zi /nologo /W3 /WX- /diagnostics:column /MP /O2 /Ob1 /D _MBCS /D WIN32 /D _WINDOWS /D NDEBUG /D AS_USE_STLNAMES /D ICEENGINE_ENABLE_DEBUG_LOGGING=1 /D FREEIMAGE_LIB /D LIBJPEG_STATIC /D OPJ_STATIC /D LIBRAW_NODLL /D LZMA_API_STATIC /D BOOST_ALL_NO_LIB /D
HAVE_BZIP2 /D GLEW_STATIC /D BOOST_STACKTRACE_USE_NOOP /D BOOST_STACKTRACE_USE_WINDBG /D BOOST_STACKTRACE_USE_WINDBG_CACHED /D "CMAKE_INTDIR=\"RelWithDebInfo\"" /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++17 /Yu"C:/Users/Jarr
ett/projects/icebreakersentertainment/dark_horizon/cmake-build-relwithdebug/ice_engine/CMakeFiles/ice_engine.dir/RelWithDebInfo/cmake_pch.hxx" /Fp"C:/Users/Jarrett/projects/icebreakersentertainment/dark_horizon/cmake-build-relwithdebug/ice_engine/ice_engine.dir
/RelWithDebInfo/cmake_pch.pch" /Fo"ice_engine.dir\RelWithDebInfo\\" /Fd"C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\cmake-build-relwithdebug\ice_engine\RelWithDebInfo\ice_engine.pdb" /external:W0 /Gd /TP /FI"C:/Users/Jarrett/projects/icebrea
kersentertainment/dark_horizon/cmake-build-relwithdebug/ice_engine/CMakeFiles/ice_engine.dir/RelWithDebInfo/cmake_pch.hxx" /errorReport:queue /external:I "C:/Users/Jarrett/.conan/data/glm/0.9.9.8/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include" /e
xternal:I "C:/.conan/781bd1/1/include" /external:I "C:/Users/Jarrett/.conan/data/zlib/1.2.13/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/libjpeg/9e/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/
include" /external:I "C:/Users/Jarrett/.conan/data/openjpeg/2.5.0/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/openjpeg/2.5.0/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include/openjpeg-2.5" /
external:I "C:/Users/Jarrett/.conan/data/libpng/1.6.40/_/_/package/dabebadc995f5604e23c1a122d0de9c5969f117d/include" /external:I "C:/Users/Jarrett/.conan/data/libwebp/1.3.1/_/_/package/35e93cf1a4892e74ea68e04ae6584a6768f1a24a/include" /external:I "C:/Users/Jarr
ett/.conan/data/openexr/2.5.7/_/_/package/2aa5020d9e2f7b83b0df2e43b910adacd7e9f6a2/include" /external:I "C:/Users/Jarrett/.conan/data/openexr/2.5.7/_/_/package/2aa5020d9e2f7b83b0df2e43b910adacd7e9f6a2/include/OpenEXR" /external:I "C:/Users/Jarrett/.conan/data/l
ibraw/0.20.2/_/_/package/a496421bcd1b2d90ac3fda7b0d1d52c7ed44a475/include" /external:I "C:/Users/Jarrett/.conan/data/lcms/2.14/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/jasper/4.0.0/_/_/package/11ae4
ebe116abe395eeda38eddb25d52a57ece3c/include" /external:I "C:/Users/Jarrett/.conan/data/jxrlib/cci.20170615/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/libtiff/4.5.1/_/_/package/1b80e1674bcaf5fcf52e6fe3
c21071c3f9644ab1/include" /external:I "C:/Users/Jarrett/.conan/data/libdeflate/1.18/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/xz_utils/5.4.2/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/inclu
de" /external:I "C:/Users/Jarrett/.conan/data/jbig/20160605/_/_/package/a4e1afe0cdf28a6e8a24a99bcef32c1d8b1b1ea6/include" /external:I "C:/Users/Jarrett/.conan/data/zstd/1.5.5/_/_/package/bb7459059ccb263b17051f13766d8a54c12f6b46/include" /external:I "C:/.conan/7
037aa/1/include" /external:I "C:/Users/Jarrett/.conan/data/assimp/5.0.1/_/_/package/934be063a75bacef3ad4a9af4906ba7a55fc0964/include" /external:I "C:/Users/Jarrett/.conan/data/irrxml/1.2/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I
"C:/Users/Jarrett/.conan/data/minizip/1.2.11/_/_/package/de4c86e8fcc00fd6629c0ab7fe86105fa6e94c66/include" /external:I "C:/Users/Jarrett/.conan/data/minizip/1.2.11/_/_/package/de4c86e8fcc00fd6629c0ab7fe86105fa6e94c66/include/minizip" /external:I "C:/Users/Jarre
tt/.conan/data/bzip2/1.0.8/_/_/package/c9a233d2162940f2b2cb0e76665ffd0126907e8f/include" /external:I "C:/Users/Jarrett/.conan/data/utfcpp/3.1.2/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include" /external:I "C:/Users/Jarrett/.conan/data/utfcpp/3.1.2/
_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/utf8cpp" /external:I "C:/Users/Jarrett/.conan/data/kuba-zip/0.1.31/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/poly2tri/cci.20130502/_/_/pac
kage/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/rapidjson/cci.20200410/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include" /external:I "C:/Users/Jarrett/.conan/data/glew/2.1.0/_/_/package/63295b0c0912b8
2fa79bfbf9508d76264b236b8d/include" /external:I "C:/Users/Jarrett/.conan/data/vulkan-headers/1.3.243.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include" /external:I "C:/Users/Jarrett/.conan/data/vulkan-headers/1.3.243.0/_/_/package/5ab84d6acfe1f23c4
fae0ab88f26e3a396351ac9/res/vulkan/registry" /external:I "C:/Users/Jarrett/.conan/data/sdl/2.28.2/_/_/package/aaaec587efc9384b1cddee85ec81c25825cb201f/include" /external:I "C:/Users/Jarrett/.conan/data/sdl/2.28.2/_/_/package/aaaec587efc9384b1cddee85ec81c25825cb
201f/include/SDL2" /external:I "C:/.conan/b5607c/1/include" /external:I "C:/Users/Jarrett/.conan/data/lua/5.4.6/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/sol2/3.3.0/_/_/package/5ab84d6acfe1f23c4fae0a
b88f26e3a396351ac9/include" /external:I "C:/Users/Jarrett/.conan/data/entityx/1.3.0/_/_/package/270dc4a2f77a5fc63ad24b950295fddb3a32f993/include" /external:I "C:/Users/Jarrett/.conan/data/ctpl/0.0.2/icebreakersentertainment/stable/package/5ab84d6acfe1f23c4fae0a
b88f26e3a396351ac9/include" C:\Users\Jarrett\projects\icebreakersentertainment\dark_horizon\ice_engine\src\Window.cpp

更多回答

do you have language extensions disabled? windows.h needs them

您是否禁用了语言扩展?Windows.h需要它们

@Raildex I have set(CMAKE_CXX_EXTENSIONS OFF) set in my CMake file, however for the actual compile command I don't see /Za or /Ze.

@raidex我在CMake文件中设置了(CMAKE_CXX_EXTENSIONS OFF),但是对于实际的编译命令,我没有看到/Za或/Ze。

优秀答案推荐
更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com