D - how do I convert this C idiom?
- Dan Liebgold (15/15) Feb 18 2003 In C/C++, I am used to building static data structures using pointers em...
- Dan Liebgold (10/21) Feb 18 2003 Of course, this seems to work:
- Walter (1/1) Feb 19 2003 They should both work; it's a compiler bug. -Walter
In C/C++, I am used to building static data structures using pointers embedded in the initializers, like so: struct NODE { int data; NODE *next; } static NODE nodetbl[3] = [ {0,&nodetbl[1]}, {0,&nodetbl[2]}, {0,null} ]; How might I do this sort of thing in D, seeing as I must only use constant initializers for arrays? Thanks, Dan
Feb 18 2003
Of course, this seems to work: static NODE nodetbl[3] = [ {0,(NODE*)nodetbl + 1}, {0,(NODE*)nodetbl + 2}, {0,null} ]; It does seem odd that ((NODE*)nodetbl + 1) is constant, but &nodetbl[1] is not. Dan In article <b2v4b4$1nti$1 digitaldaemon.com>, Dan Liebgold says...In C/C++, I am used to building static data structures using pointers embedded in the initializers, like so: struct NODE { int data; NODE *next; } static NODE nodetbl[3] = [ {0,&nodetbl[1]}, {0,&nodetbl[2]}, {0,null} ];
Feb 18 2003
They should both work; it's a compiler bug. -Walter
Feb 19 2003