SDL_Texture - 不完整类型 [英] SDL_Texture - Incomplete type
问题描述
一天前我安装了一个SDL2库。它不是在Debian Wheezy,所以我使用 configure,make,make install
命令。
a day ago I installed an SDL2 library. It is not in Debian Wheezy yet, so I used configure, make, make install
commands.
当我尝试使用SDL_Texture,我得到这个错误:
After all, when I try to use SDL_Texture, I get this error:
error: forward declaration of ‘SDL_Texture {aka struct SDL_Texture}’
invalid use of incomplete type ‘SDL_Texture {aka struct SDL_Texture}’
我找到的是SDL_render.h中的这两行:
After looking for declaration, everything I found are these two lines in SDL_render.h:
struct SDL_Texture;
typedef struct SDL_Texture SDL_Texture;
没有定义。我认为我的安装缺少文件SDL_sysrender.h。它是在源代码我下载的,但不是在SDL2包含路径。
No definition at all. I think my installation is missing file SDL_sysrender.h. It is in source code I downloaded, but not in SDL2 include path.
问题应该在哪里?它必须使用任何标志配置文件?
感谢您的帮助。
Where should be the problem? Its necessary to use any flag for configure file? Thank you for help.
推荐答案
安装没有问题。 SDL_Texture是一个不透明类型的设计(也就是说,设计为只能由SDL2内部操作),你可以传递作为一个指针,但你不能访问内部(或创建一个SDL_Texture自己,例如通过做一个malloc,因为你不知道结构的大小)。如果你坚持
There's nothing wrong with your install. SDL_Texture is an opaque type by design (that is, designed to only be operated on by SDL2 internally), you can "pass it around" as a pointer, but you can't access the internals (or create a SDL_Texture yourself, for example by doing a malloc, because you don't know the size of the structure). If you stick to
SDL_Texture *blah;
指针,并传递给SDL2函数,你应该很好。
pointers and pass them around to the SDL2 functions you should be fine.
SDL_sysrender.h是一个内部头,如前所述,实际上定义了SDL_Texture用于库的内部使用。
SDL_sysrender.h is an internal header which, as you mentioned, actually defines SDL_Texture for internal consumption of the library.
这篇关于SDL_Texture - 不完整类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!