Thread overview
No dynamic Arrays in Struct?
Feb 10, 2007
Manfred Nowak
Feb 10, 2007
torhu
Feb 10, 2007
Manfred Nowak
February 10, 2007
void main(){
  struct S{
    int[] map;
    map.length= 1000; // error: no identifier for declarator map.length
  } S s;
}

-manfred
February 10, 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.
February 10, 2007
torhu wrote
> You can't have an assignment in the struct definition.

Oooops. Thank you. I was misleaded by the error message.

-manfred
February 10, 2007
Manfred Nowak wrote:
> torhu wrote
>> You 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
February 11, 2007
"Chris Nicholson-Sauls" <ibisbasenji@gmail.com> wrote in message news:eql1r2$a2f$1@digitaldaemon.com...
> Manfred Nowak wrote:
>> torhu wrote
>>> You 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#...