digitalmars.D.learn - Array of BitArrays definition compiles in DMD but not in GDC.
- TheGag96 (16/16) Oct 08 2015 In my code I'm passing an array of BitArrays to a constructor
- John Colvin (17/33) Oct 09 2015 gdc is a bit out of date at the moment. If you do something like
- TheGag96 (4/22) Oct 09 2015 That appears to work, although the compiler was complaining that
In my code I'm passing an array of BitArrays to a constructor like this (though mostly as a placeholder): Terrain t = new Terrain(1, 15, [ BitArray([1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), BitArray([1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]), ]); The code compiles fine when using DMD 2.068.1 but GDC 5.2.1, I get this error for every line: error: cannot implicityly convert expression ([stuff]) of type int[] to ulong Why does this compiler difference exist and how do I get around it? Thanks!
Oct 08 2015
On Thursday, 8 October 2015 at 21:40:02 UTC, TheGag96 wrote:In my code I'm passing an array of BitArrays to a constructor like this (though mostly as a placeholder): Terrain t = new Terrain(1, 15, [ BitArray([1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), BitArray([1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), BitArray([1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]), ]); The code compiles fine when using DMD 2.068.1 but GDC 5.2.1, I get this error for every line: error: cannot implicityly convert expression ([stuff]) of type int[] to ulong Why does this compiler difference exist and how do I get around it? Thanks!gdc is a bit out of date at the moment. If you do something like this: auto bitArray(bool[] ba) pure nothrow { BitArray tmp; tmp.init(ba); return tmp; } auto bitArray(void[] v, size_t numbits) pure nothrow { BitArray tmp; tmp.init(v, numbits); return tmp; } then replace all your calls to the constructor BitArray with bitArray, things should work OK for you.
Oct 09 2015
On Friday, 9 October 2015 at 07:08:15 UTC, John Colvin wrote:On Thursday, 8 October 2015 at 21:40:02 UTC, TheGag96 wrote:That appears to work, although the compiler was complaining that the calls to init were not pure nor nothrow. Thanks! Hopefully they'll update GDC soon.[...]gdc is a bit out of date at the moment. If you do something like this: auto bitArray(bool[] ba) pure nothrow { BitArray tmp; tmp.init(ba); return tmp; } auto bitArray(void[] v, size_t numbits) pure nothrow { BitArray tmp; tmp.init(v, numbits); return tmp; } then replace all your calls to the constructor BitArray with bitArray, things should work OK for you.
Oct 09 2015