digitalmars.D.learn - No dynamic Arrays in Struct?
- Manfred Nowak <svv1999 hotmail.com> Feb 09 2007
- torhu <fake address.dude> Feb 10 2007
- Manfred Nowak <svv1999 hotmail.com> Feb 10 2007
- Chris Nicholson-Sauls <ibisbasenji gmail.com> Feb 10 2007
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Feb 10 2007
void main(){
struct S{
int[] map;
map.length= 1000; // error: no identifier for declarator map.length
} S s;
}
-manfred
Feb 09 2007
Manfred Nowak wrote:void main(){ struct S{ int[] map; map.length= 1000; // error: no identifier for declarator map.length } S s; }
You can't have an assignment in the struct definition. Try just using 'int[1000] map;' instead. Or set the size in a function, if you want to have a dynamic array with preset length.
Feb 10 2007
torhu wroteYou can't have an assignment in the struct definition.
Oooops. Thank you. I was misleaded by the error message. -manfred
Feb 10 2007
Manfred Nowak wrote:torhu wroteYou can't have an assignment in the struct definition.
Oooops. Thank you. I was misleaded by the error message. -manfred
Try struct S { int[] map = new int[1000]; } /Should/ work I believe, if you really want the length dynamic. -- Chris Nicholson-Sauls
Feb 10 2007
"Chris Nicholson-Sauls" <ibisbasenji gmail.com> wrote in message news:eql1r2$a2f$1 digitaldaemon.com...Manfred Nowak wrote:torhu wroteYou can't have an assignment in the struct definition.
Oooops. Thank you. I was misleaded by the error message. -manfred
Try struct S { int[] map = new int[1000]; } /Should/ work I believe, if you really want the length dynamic.
You can't have non-static initializers for aggregate member declarations. That's one thing I wish D would take from Java/C#...
Feb 10 2007








"Jarrett Billingsley" <kb3ctd2 yahoo.com>