digitalmars.D - Dynamic array of pointers to opaque structs
- Johan F. (33/33) Jun 05 2013 I'm fiddling around with SDL2 using Derelict3, and I'm trying to
- Timon Gehr (3/34) Jun 05 2013 It is a compiler bug, but we cannot confirm it unless you provide a
- Johan F. (10/67) Jun 05 2013 This triggers it (2.063):
- Adam D. Ruppe (9/12) Jun 05 2013 Just guessing here, what happens if you make that
- Johan F. (3/15) Jun 05 2013 Ok, thanks. I'll just add {} then, until the bug(?) gets fixed.
- Mike Parker (5/38) Aug 28 2013 For anyone stumbling across this thread in the future, there's a
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?
Jun 05 2013
On 06/05/2013 10:34 PM, 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?It is a compiler bug, but we cannot confirm it unless you provide a minimal example that triggers it.
Jun 05 2013
On Wednesday, 5 June 2013 at 20:37:27 UTC, Timon Gehr wrote:On 06/05/2013 10:34 PM, Johan F. wrote:This triggers it (2.063): struct something; int main() { something*[] stuff; something* a; stuff ~= a; return 0; }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?It is a compiler bug, but we cannot confirm it unless you provide a minimal example that triggers it.
Jun 05 2013
On Wednesday, 5 June 2013 at 20:34:17 UTC, Johan F. wrote:struct SDL_Texture;Just guessing here, what happens if you make that extern(C) struct SDL_Texture; ?Also, is simply adding {} the right way of fixing it, or will that possibly break something else?This shouldn't break anything since it is just adding RTTI info to D (opCmp, toHash, etc, are members of the D TypeInfo for this struct. why they are required in this case is beyond me). It doesn't change the actual core of the code, which are still just pointers.
Jun 05 2013
On Wednesday, 5 June 2013 at 20:38:08 UTC, Adam D. Ruppe wrote:On Wednesday, 5 June 2013 at 20:34:17 UTC, Johan F. wrote:It doesn't change anything.struct SDL_Texture;Just guessing here, what happens if you make that extern(C) struct SDL_Texture; ?Ok, thanks. I'll just add {} then, until the bug(?) gets fixed.Also, is simply adding {} the right way of fixing it, or will that possibly break something else?This shouldn't break anything since it is just adding RTTI info to D (opCmp, toHash, etc, are members of the D TypeInfo for this struct. why they are required in this case is beyond me). It doesn't change the actual core of the code, which are still just pointers.
Jun 05 2013
It's not a bug: http://dblog.aldacron.net/forum/index.php?topic=820.0
Jun 05 2013
On Wednesday, 5 June 2013 at 20:51:03 UTC, Namespace wrote:It's not a bug: http://dblog.aldacron.net/forum/index.php?topic=820.0Hmm, that thread seems to address something else? I'm talking about simply making an array of pointers to opaque structs, which
Jun 05 2013
Oh ok. I thought you suspect a bug in Derelict.
Jun 05 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
Aug 28 2013