Example error for initializer?

Chris Miller chris at dprogramming.com
Wed Jun 21 06:56:06 PDT 2006


On Wed, 21 Jun 2006 17:01:11 -0400, Paolo Invernizzi  
<arathorn at NOSPAM_fastwebnet.it> wrote:

> Hi all,
>
> In http://www.digitalmars.com/d/arrays.html under Pointer Arithmetic  
> there's:
>
> int[] def = [ 1, 2, 3 ];	// dynamic array of 3 ints
>
> but does not compile (dmd .0161):
>
>    variable xdelta.main.def is not a static and cannot have static  
> initializer
>
> Example error?
>
> ---
> Paolo Invernizzi

DMD doesn't support it yet for non-static, non-const; here is a workaround:

    const int[] _def_init = [ 1, 2, 3 ];
    int[] def = _def_init;



More information about the Digitalmars-d-learn mailing list