Basic question about size_t and ulong

Steven Schveighoffer schveiguy at gmail.com
Mon Mar 21 13:05:45 UTC 2022


On 3/18/22 7:01 PM, Ali Çehreli wrote:
> On 3/18/22 14:54, WhatMeWorry wrote:
>  > size_t huge = uint.max;  // compiles
> 
> That means size_t is uint on that build.

Not that Ali is wrong in the full sense, but this line alone will 
compile on both 64 and 32-bit systems, so it is not informative. 
However, the fact that assigning it to `ulong.max` doesn't work coupled 
with this means that it's 32-bit.

You can use code like this to tell you what your platform bits are:

```d
pragma(msg, cast(int)(size_t.sizeof * 8), " bit");
```

-Steve


More information about the Digitalmars-d-learn mailing list