3 ms·
Interestingly, a complete implementation of strtol [1] is shorter than this wrapper. If you don't like strtol's API or error handling, just implement your own.
by cmovq 1y ago
Interestingly, a complete implementation of strtol [1] is shorter than this wrapper. If you don't like strtol's API or error handling, just implement your own.
[1]: https://github.com/gcc-mirror/gcc/blob/master/libiberty/strtol.c#L90 https://github.com/gcc-mirror/gcc/blob/master/libiberty/strt...
> If an overflow is detected, it calls abort()
An aside, but this doesn't detect overflows on Windows due to both long and int being 32 bits (you'd want strtoll for that).