Compile time static array issues.
Robert Clipsham
robert at octarineparrot.com
Sat May 28 15:58:08 PDT 2011
On 28/05/2011 23:57, Era Scarecrow wrote:
> I don't seem to have a good explanation why this isn't working. All i end up
> getting is 'Error: cannot implicitly convert expression .... of type
> string[][] to joined[]'. I also get 'incompatible types for (("AADT") ? (16)):
> 'string' and 'int''. I've tried it with casts, and full array qualifiers.
>
> I'm using DMD 2.053.
>
> --
>
> struct joined {
> string name;
> string partof;
> string preReq;
> }
>
> struct subrecord_parts {
> string name;
> int size;
> string[] notes;
> int identifyBy;
> int[] partSize;
> }
>
> joined[] attached;
> subrecord_parts[] parts;
>
> static this() {
> attached = [
> ["MAST", "DATA", "TES3"],
> ["ANAM","INTV", "FACT"]];
try attached = [joined("MAST", "DATA", "TES3"), joined("ANAM", "INTV",
"FACT")];
>
> parts = [
> ["AADT", 16, ["fWeight", "iValue", "iUses", "fQuality"], -1, [4,4,4,4]],
> ["AODT", 24, ["iType", "fWeight", "iValue", "iHealth", "iEnchant Points",
> "iArmour"], -1, [4,4,4,4,4,4]]];
Similar here, parts = [ subrecord_parts("AADT", 16, ["fWeight",
"iValue", "iUses", "fQuality"], -1, [4,4,4,4]), subrecord_parts(...)]; etc.
> }
>
> -- output
> test.d(20): Error: cannot implicitly convert expression
> ([["MAST","DATA","TES3"],["ANAM","INTV","FACT"]]) of type string[][] to joined[]
> Error: incompatible types for (("AADT") ? (16)): 'string' and 'int'
> Error: incompatible types for (("AODT") ? (24)): 'string' and 'int'
> test.d(26): Error: cannot implicitly convert expression
> ([[(__error),(__error),(__error),(__error),(__error)],[(__error),(__error),(__error),(__error),(__error)]])
> of type _error_[][] to subrecord_parts[]
--
Robert
http://octarineparrot.com/
More information about the Digitalmars-d-learn
mailing list