2 ms·
Why do you use "(void)gettimeofday(&start, NULL);" instead of just "gettimeofday(&start, NULL);"?
by Sohcahtoa82 8y ago
Why do you use "(void)gettimeofday(&start, NULL);" instead of just "gettimeofday(&start, NULL);"?
- AceJohnny2 8y agoTo avoid the compiler complaining about the unused return value, by telling it I'm explicitly choosing to ignore the value. The complaint doesn't show up on the default warning levels. I think only with -W ? (fun fact: -Wall actually has fewer warnings enabled than -W, at least with Clang) Edit: actually, the warning is enabled by default, but only triggers for functions that have the attribute 'warn_unused_result' set, which is almost none of them, which is why this warning is not well-known. Indeed, in my example my (void) isn't necessary, and I couldn't get the warning to trigger even with -Wpedantic.