On Monday, February 14, 2011 16:30:09 Andrej Mitrovic wrote: > Here's something I've noticed (x86 code): > > void main() > { > ulong size = 2; > int[] arr = new int[](size); > } > > This will error with: > sizetTest.d(8): Error: cannot implicitly convert expression (size) of > type ulong to uint > > size_t is aliased to uint since I'm running 32bit. > > I'm really not experienced at all with 64bit, so I don't know if it's > good to use uint explicitly (my hunch is that it's not good). uint as > the array size wouldn't even compile in 64bit, right? > > If I'm correct, wouldn't it be better if the error showed that it > expects size_t which might be aliased to whatever type for a > particular machine?
Use size_t. It's the type which is used. It's aliased to whichever type is appropriate for the architecture. On 32 bits, that would be a 32 bit integer, so it's uint. On 64 bits, that would be a 64 bit integer, so it's ulong. - Jonathan m Davis