3 ms·
tl;dr #include <stdckdint.h> bool ckd_add(type1 *result, type2 a, type3 b); bool ckd_sub(type1 *result, type2 a, type3 b); bool ckd_mul(type1
by tinglymintyfrsh 4y ago
tl;dr
#include <stdckdint.h>
bool ckd_add(type1 *result, type2 a, type3 b);
bool ckd_sub(type1 *result, type2 a, type3 b);
bool ckd_mul(type1 *result, type2 a, type3 b);
#include <stdckdint.h>
#include <limits.h>
/* ... */
int x;
int a = INT_MAX;
int b = INT_MAX;
if (!chk_add(&x, a, b)) {
/* error! */
}
Other stuff on the table for C23
- https://thephd.dev/c-the-improvements-june-september-virtual-c-meeting https://thephd.dev/c-the-improvements-june-september-virtual...
- (PDF) https://open-std.org/jtc1/sc22/wg14/www/docs/n3054.pdf https://open-std.org/jtc1/sc22/wg14/www/docs/n3054.pdf
- heywhatupboys 4y ago> if (!chk_add(&x, a, b)) { > /* error! */ > } does it return non-zero on success???
- EdSchouten 4y agoIt returns a boolean.
- tinglymintyfrsh 4y agoThey're using a bool, so it violates the old-school C paradigm used for library calls. This is more of a macro rather than a syscall or standard library function call.
- comex 4y agoYou have it backwards: it returns true on error.
- RustyRussell 4y agoLet's take this as evidence that the proposal is counter-intuitive?