问题
a day ago I installed an SDL2 library. It is not in Debian Wheezy yet, so I used configure, make, make install
commands.
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}’
After looking for declaration, everything I found are these two lines in SDL_render.h:
struct SDL_Texture;
typedef struct SDL_Texture SDL_Texture;
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.
回答1:
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;
pointers and pass them around to the SDL2 functions you should be fine.
SDL_sysrender.h is an internal header which, as you mentioned, actually defines SDL_Texture for internal consumption of the library.
来源:https://stackoverflow.com/questions/18897076/sdl-texture-incomplete-type