warn_unused_result
The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug, such as realloc.
int fn () __attribute__ ((warn_unused_result));
int foo ()
{
if (fn () < 0) return -1;
fn ();
return 0;
}
復制代碼
results in warning on line 5. 作者: tempname2 時間: 2011-11-15 11:36
不知道有沒有通用選項,可以用lint,到時候你就得(void)printf (...)了作者: 帥絕人寰 時間: 2012-01-13 13:07