digitalmars.D - DMD32 vs DMD64 array.length
- Andrea Fontana (3/3) Nov 10 2011 Some functions (for example array length) return ulong on dmd64 e uint
- Dejan Lekic (2/5) Nov 10 2011 Andrea, use the size_t type.
- Andrea Fontana (9/16) Nov 11 2011 That's exactly what I was looking for. So it works as in most
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (4/20) Nov 11 2011 DMD generally uses the actual type rather than the alias' name when
- Andrea Fontana (13/38) Nov 11 2011 I don't think it's a good idea. In this case it's my fault, I should
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (3/36) Nov 11 2011 I agree, that could be useful. Could you file a Bugzilla bug?
- bearophile (4/5) Nov 11 2011 See bug 5004.
- Steven Schveighoffer (10/12) Nov 11 2011 size_t is not a builtin type. It's aliased to ulong or uint depending o...
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (4/7) Nov 10 2011 I don't understand what your actual question is, but size_t is what you
Some functions (for example array length) return ulong on dmd64 e uint on dmd32=20 I need to compile on both platform: which is the right/best/clean way?
Nov 10 2011
Andrea Fontana wrote:Some functions (for example array length) return ulong on dmd64 e uint on dmd32 I need to compile on both platform: which is the right/best/clean way?Andrea, use the size_t type.
Nov 10 2011
That's exactly what I was looking for. So it works as in most programming languages :P=20 Dmd has deceived me. It says: "Error: cannot implicitly convert expression (leaves.length) of type ulong to uint" It should say: "Error: cannot implicitly convert expression (leaves.length) of type size_t to uint" Il giorno gio, 10/11/2011 alle 15.19 +0000, Dejan Lekic ha scritto:Andrea Fontana wrote: =20Some functions (for example array length) return ulong on dmd64 e uint on dmd32 I need to compile on both platform: which is the right/best/clean way?=20 Andrea, use the size_t type.
Nov 11 2011
On 11-11-2011 09:30, Andrea Fontana wrote:That's exactly what I was looking for. So it works as in most programming languages :P Dmd has deceived me. It says: "Error: cannot implicitly convert expression (leaves.length) of type ulong to uint" It should say: "Error: cannot implicitly convert expression (leaves.length) of type size_t to uint" Il giorno gio, 10/11/2011 alle 15.19 +0000, Dejan Lekic ha scritto:DMD generally uses the actual type rather than the alias' name when you're using an aliased type. - AlexAndrea Fontana wrote:Some functions (for example array length) return ulong on dmd64 e uint on dmd32 I need to compile on both platform: which is the right/best/clean way?Andrea, use the size_t type.
Nov 11 2011
I don't think it's a good idea. In this case it's my fault, I should imagine that a size_t datatype exists for arrays. BTW on generic cases with aliases it would be useful to have an error like : "Error: cannot implicity convert expression (leaves.length) of type size_t (ulong) to uint." If not, i'll fix it using ulong and then when i'll go back on 32bit (or on a case where alias is defined in another way) compiling will fail again. Il giorno ven, 11/11/2011 alle 09.58 +0100, Alex R=C3=B8nne Petersen ha scritto:On 11-11-2011 09:30, Andrea Fontana wrote:intThat's exactly what I was looking for. So it works as in most programming languages :P Dmd has deceived me. It says: "Error: cannot implicitly convert expression (leaves.length) of type ulong to uint" It should say: "Error: cannot implicitly convert expression (leaves.length) of type size_t to uint" Il giorno gio, 10/11/2011 alle 15.19 +0000, Dejan Lekic ha scritto:Andrea Fontana wrote:Some functions (for example array length) return ulong on dmd64 e u=ay?on dmd32 I need to compile on both platform: which is the right/best/clean w==20 DMD generally uses the actual type rather than the alias' name when=20 you're using an aliased type. =20 - AlexAndrea, use the size_t type.
Nov 11 2011
On 11-11-2011 10:13, Andrea Fontana wrote:I don't think it's a good idea. In this case it's my fault, I should imagine that a size_t datatype exists for arrays. BTW on generic cases with aliases it would be useful to have an error like : "Error: cannot implicity convert expression (leaves.length) of type size_t (ulong) to uint." If not, i'll fix it using ulong and then when i'll go back on 32bit (or on a case where alias is defined in another way) compiling will fail again. Il giorno ven, 11/11/2011 alle 09.58 +0100, Alex Rønne Petersen ha scritto:I agree, that could be useful. Could you file a Bugzilla bug? - AlexOn 11-11-2011 09:30, Andrea Fontana wrote:That's exactly what I was looking for. So it works as in most programming languages :P Dmd has deceived me. It says: "Error: cannot implicitly convert expression (leaves.length) of type ulong to uint" It should say: "Error: cannot implicitly convert expression (leaves.length) of type size_t to uint" Il giorno gio, 10/11/2011 alle 15.19 +0000, Dejan Lekic ha scritto:DMD generally uses the actual type rather than the alias' name when you're using an aliased type. - AlexAndrea Fontana wrote: > Some functions (for example array length) return ulong on dmd64 e uint > on dmd32 > I need to compile on both platform: which is the right/best/clean way? Andrea, use the size_t type.
Nov 11 2011
Alex R. Petersen:I agree, that could be useful. Could you file a Bugzilla bug?See bug 5004. Bye, bearophile
Nov 11 2011
On Fri, 11 Nov 2011 04:13:21 -0500, Andrea Fontana <advmail katamail.com> wrote:I don't think it's a good idea. In this case it's my fault, I should imagine that a size_t datatype exists for arrays.size_t is not a builtin type. It's aliased to ulong or uint depending on the architecture. The compiler is not aware of size_t. However, given that the compiler has some quirky knowledge of phobos (i.e. if you use writeln without importing std.stdio, it gives you a helpful message about importing it), I would think we could do something along the same lines for array.length. -Steve
Nov 11 2011
On 10-11-2011 16:18, Andrea Fontana wrote:Some functions (for example array length) return ulong on dmd64 e uint on dmd32 I need to compile on both platform: which is the right/best/clean way?I don't understand what your actual question is, but size_t is what you should use for such things. (size_t == uint on x86, ulong on x86-64.) - Alex
Nov 10 2011