The problem is it needs to be applied to every function that returns a value. And I'm pretty sure you can't apply it to C library functions. Gcc seriously needs a global flag for this.
int written = printf("Got here");
if (written != sizeof("Got here") - 1) {
written = fprintf(stderr, "Could not print my sacred message\n");
if (written != sizeof("Could not print my sacred message\n") - 1) {
exit(I_DONT_KNOW_WTF_IS_HAPENNING_HERE);
}
}You made a small mistake, since fprintf and printf call the same underlying code, the error handling should be either log the error in any way still available, and then depending on the design of the whole program, exit or continue. If printf fails you know exactly what is going on or have to exit. ( And printf would be wrapped in a function if you plan to use it repeatedly. )