I\'m working on some code that generates a lot of
ignoring return value of ‘size_t fwrite(const void*, size_t, size_t, FILE*)’, declared with attribute warn
Ok, given that I'm looking for a c solution (no exceptions), how about:
void safe_fwrite(data,size,count,fp) {
if (fwrite(data,size,count,fp) != count) {
printf("[ERROR] fwrite failed!\n");
fclose(fp);
exit(4);
}
}
And then in my code I have:
safe_fwrite (&blah, sizeof (blah), 1, fp);
// ... more code ...
safe_fwrite (&foo, sizeof (foo), 1, fp);
// ... more code ...