Dynamic array of pointers to opaque structs
Mike Parker
aldacron at gmail.com
Wed Aug 28 20:40:18 PDT 2013
On Wednesday, 5 June 2013 at 20:34:17 UTC, Johan F. wrote:
> I'm fiddling around with SDL2 using Derelict3, and I'm trying
> to make an array of SDL_Texture pointers, like so:
>
> SDL_Texture*[] frames;
> ... make texture ...
> frames ~= texture;
>
> However, this yields the following error:
>
> /Users/jaffe1/prog/Derelict3/import/derelict/sdl2/types.d(1865):
> Error: struct derelict.sdl2.types.SDL_Texture is forward
> referenced when looking for 'toHash'
> /Users/jaffe1/prog/Derelict3/import/derelict/sdl2/types.d(1865):
> Error: struct derelict.sdl2.types.SDL_Texture is forward
> referenced when looking for 'opCmp'
> /Users/jaffe1/prog/Derelict3/import/derelict/sdl2/types.d(1865):
> Error: struct derelict.sdl2.types.SDL_Texture is forward
> referenced when looking for 'toString'
> /Users/jaffe1/prog/Derelict3/import/derelict/sdl2/types.d(1865):
> Error: struct derelict.sdl2.types.SDL_Texture unknown size
> /Users/jaffe1/prog/Derelict3/import/derelict/sdl2/types.d(1865):
> Error: struct derelict.sdl2.types.SDL_Texture no size yet for
> forward reference
> /Users/jaffe1/prog/Derelict3/import/derelict/sdl2/types.d(1865):
> Error: struct derelict.sdl2.types.SDL_Texture unknown size
> /Users/jaffe1/prog/Derelict3/import/derelict/sdl2/types.d(1865):
> Error: struct derelict.sdl2.types.SDL_Texture no size yet for
> forward reference
>
> At line 1865 in types.d is the opaque struct declaration
>
> struct SDL_Texture;
>
> The program compiles and works fine if I change this line to
>
> struct SDL_Texture {};
>
> This seems weird to me. Why is making an array of _pointers_ to
> SDL_Texture dependant on how the SDL_Texture struct is
> declared? Also, is simply adding {} the right way of fixing it,
> or will that possibly break something else?
For anyone stumbling across this thread in the future, there's a
report for this in bugzilla[1]. It's an issue in the compiler
with the handling of opaque structs.
[1] http://d.puremagic.com/issues/show_bug.cgi?id=10451
More information about the Digitalmars-d
mailing list