Basic question about size_t and ulong

Era Scarecrow rtcvb32 at
Tue Mar 22 18:28:22 UTC 2022

On Friday, 18 March 2022 at 23:01:05 UTC, Ali Çehreli wrote:
> 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().

  Perhaps we should back up and ask a different question. I've 
been working on adaptation of Reed Solomon Codes, and i keep 
getting thrown with casting errors, to the point where i just 
want to make everything size_t to make the errors go away.

  So when should you use size_t? Is it better to use int, long, 
size_t? Or is it better to try to use the smallest type you need 
that will fulfill the function's needs and just add to handle 
issues due to downcasting?

More information about the Digitalmars-d-learn mailing list