Basic question about size_t and ulong
Ali Çehreli
acehreli at yahoo.com
Fri Mar 18 23:01:05 UTC 2022
On 3/18/22 14:54, WhatMeWorry wrote:
> size_t is an alias to one of the unsigned integral basic types, and
> represents a type that is large enough to represent an offset into all
> addressable memory.
In practice, that general description means "size_t is either ulong or
uint" depending on your platform (or build e.g. -m32 as Adam said).
> size_t huge = uint.max; // compiles
That means size_t is uint on that build.
Ali
P.S. On a related note, I used to make the mistake of using size_t for
file offsets as well. That is a mistake because even on a 32-bit system
(or build), file sizes can be larger than uint.max. So, the correct type
is long for seek() so that we can seek() to an earlier place and ulong
for tell().
More information about the Digitalmars-d-learn
mailing list