SDL_Texture - 不完整类型 [英] SDL_Texture - Incomplete type

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

问题描述

一天前我安装了一个 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屋!

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