Hacker News new | ask | show | jobs
by rantouan 400 days ago
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.

1 comments

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.