3 ms·
Using integer codes like 0 and -1 were the old style of returning errors. Often combined with some undocumented features. It is really wrong, but that is cause
by zyxzevn 7y ago
Using integer codes like 0 and -1 were the old style of returning errors. Often combined with some undocumented features.
It is really wrong, but that is caused by the C-functions returning only one integer of data. And the bad C libraries. Null used to be -1 in some compilers. Mixing pointers as integers is a recipe for disaster, not compatible with some CPU-s, but it is C-standard.
In the windows32 API they improved it a bit, with functions that only returned an Error code. They required struct addresses in which results were placed. I think that the process structure is also a lot better than the fork() function.
- kabdib 7y agoIt's even more fun when you're mixing libraries, and some of them return 1 on success, some of them return zero, and some -1, and you can't tell by inspection which is which. Bonus points if the API you're using inconsistently mixes boolean, null-pointer, HRESULT, DWORD, and returning a status in a value you pass a pointer to (you did initialize that value, right?) Why do we keep doing this to ourselves?