logoalt Hacker News

uecker • today at 4:49 PM • 1 reply • view on HN

The way to deal with APIs which use size_t and which works for me is to convert at the last moment.


Replies

wahern • today at 6:19 PM

I'll have to more carefully read some of your code sometime. Any links to good exemplars? I'll admit I should be more amenable to making use of signed, and I wouldn't have said that several years ago.

At the same time, the more I employ overflow checking routines[1], the less interest I have in the whole debate. Those routines cut both ways as they also make it safer to mix signed and unsigned.

[1] GCC/clang builtins, which IIUC the new C2y API mirrors. The return value semantic is unfortunate, especially in C2y where they lack the "overflow" name prefix, but it's understandable why C2y had to copy it.