Array declaration warning
Alex Parrill via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jun 2 09:22:57 PDT 2015
On Tuesday, 2 June 2015 at 16:17:23 UTC, Paul wrote:
> This array of structures...
>
> CoOrd pathList[NumPaths][];
>
> generates a warning when compiled with DMD 32 bit -w flag, but
> not 64 bit.
This gives me a warning using rdmd on x64 XUbuntu.
> If I correct the declaration to 'D style'
>
> CoOrd[NumPaths][] pathList;
>
> It compiles without warning but I cannot append items to the
> array like this...
>
> pathList[n] ~= CoOrd(cX, cY);
>
> What am I doing wrong?
`CoOrd[NumPaths]` is a fixed-length array type containing
`NumPaths` elements. You can't append to it. `CoOrd[NumPaths][]`
is a dynamic array of such arrays, but `pathList[n]` gets one of
the fixed-length arrays from the dynamic array.
Perhaps you mean `CoOrd[][NumPaths]`?
More information about the Digitalmars-d-learn
mailing list