News for hackers. Stuff that matters.
Re:Ratatoi is a C libary that wraps stdlib's strtol (as atoi... by eqvinox on Wednesday May 21, 2025 @09:17PM (#44057833)
"long" is not guaranteed to be larger than "int", and in fact it isn't on 64-bit Windows. (Let alone 32-bit platforms in general.)

https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_m...

You need to use "long long" or "intmax_t" (and matching strtoll/strtoimax)

Re:Ratatoi is a C libary that wraps stdlib's strtol (as atoi... by rantouan on Thursday May 22, 2025 @10:41AM (#44062572)
overflow problems, which I try to avoid, start only if its bigger than int.

So I had assumed that in my case I'm alright. Do you see any change needed that I can't see ?

---

Maybe a good idea would had been to go by platform or architecture and use some macros to do the check only if it's really needed. What do you think of it ? How would you implement it ?

You can make a pull request as well.

Re:Ratatoi is a C libary that wraps stdlib's strtol (as atoi... by eqvinox on Thursday May 22, 2025 @01:01PM (#44064067)
If strtol reliably sets errno to ERANGE, you're fine (you'll get a compiler warning for "if (aLong < INT_MIN || aLong > INT_MAX) {" though, because it can never be true.)

I have no idea what the cross-platform reliability of strtol() is, regarding errno. Should be fine, I hope.