为什么 SDL_Window 是不完整的类型? [英] Why SDL_Window is an incomplete type?

查看:51
本文介绍了为什么 SDL_Window 是不完整的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将使用 SDL 1.2 的 C++ 游戏移植到 SDL2 和 Android 平台.到目前为止一切都很顺利,除了一件事:当我尝试访问 SDL_Window 的字段时,编译器告诉我

I am porting to SDL2 and the Android platform a C++ game that uses SDL 1.2. Everything went well so far except for one thing: when I try to access the fields of SDL_Window, the compiler tells me

error: invalid use of incomplete type 'SDL_Window {aka struct SDL_Window}'

我认为我的 SDL 安装可能有问题.我已经使用以下命令从 libsdl.org 上的源代码编译了 SDL 2.0.0:

I think my installation of SDL may be faulty. I have compiled SDL 2.0.0 from the source found on libsdl.org using the folloing command:

ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_PLATFORM=android-18

然后,我将新构建的 libSDL2.so 复制到 $ANDROID_TOOLCHAIN/sysroot/usr/libinclude/ 中的文件> $ANDROID_TOOLCHAIN/sysroot/usr/include/SDL 中的目录.这些文件提供给 CMake 并由游戏代码引用.我设法转换了每个 SDL 调用,现在我被这个 SDL_Window 问题困住了.

Then, I have copied the freshly built libSDL2.so into $ANDROID_TOOLCHAIN/sysroot/usr/lib and the files in the include/ directory in $ANDROID_TOOLCHAIN/sysroot/usr/include/SDL. These files are given to CMake and referenced by the game's code. I managed to convert every SDL calls and now I am stuck with this SDL_Window problem.

我在 SDL 的源代码中进行了快速搜索,发现 SDL.h 包含 SDL_video.h,其中包含 SDL_Window 上的 typedef SDL_Window代码>结构 SDL_Window.然后我搜索了这个结构,除了在原始源档案中,在一个名为 src/video/SDL_sysvideo.h 的文件中,没有找到任何东西.由于它不是 API 的文件,我怀疑我是否必须将它包含在我的代码中.

I did a quick search in SDL's source code and found that SDL.h includes SDL_video.h which contains a typedef SDL_Window on struct SDL_Window. Then I searched for this struct and did not find anything except in the original source archive, in a file named src/video/SDL_sysvideo.h. Since it is not a file of the API, I doubt I have to include it in my code.

那么,对于 Android(如果相关),如何在 SDL2 中找到 SDL_Window 的定义?

So, how to find a definition of SDL_Window in SDL2, for Android (if this is relevant)?

推荐答案

问题似乎是缺乏对 SDL 2 的 API 的了解.让我们记住,不能访问 struct SDL_Window 的字段:有一些函数可以获取窗口的大小和标志,例如 SDL_GetWindowFlagsSDL_GetWindowSize.

It appears that the problem is a lack of knowledge of SDL 2's API. Let's remember that one does not access the fields of struct SDL_Window: there are functions to get the size and the flags of the window, such as SDL_GetWindowFlags and SDL_GetWindowSize.

所以问题绝对与 SDL 的安装或 Android 版本无关.抱歉浪费时间,网络人士.

So the problem is absolutely not related to the installation of the SDL or to Android builds. Sorry for the waste of time, people of the Web.

这篇关于为什么 SDL_Window 是不完整的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆