64 bit size_t

Kapps opantm2+spam at gmail.com
Mon Feb 17 01:28:12 PST 2014


On Monday, 17 February 2014 at 07:46:02 UTC, Steve Teale wrote:
> On Monday, 17 February 2014 at 07:17:06 UTC, Steve Teale wrote:
>
>>> What is size_t for 64 bit?
>>>
>>> Steve
>>
>> Sorry parent.children is just a straightforward array
>
> Sorry again - forget about it. I'd forgotten that D actually 
> says int is 32 bits, and ulong is 64, and size_t for a 64 bit 
> machine is obviously 64.
>
> I'll just go through the code and either change int to ulong or 
> use a cast.
>
> ;=(

Rather than change it to int/ulong, just change it to 'size_t len 
= parent.children.length+1' (or auto instead of size_t). This way 
it's proper for both 32-bit and 64-bit and you don't need to 
worry about architecture. If you do need a signed version, you 
can use ptrdiff_t.


More information about the Digitalmars-d-learn mailing list