Problem statement
I use a return integer to propagate errors through my code. I would like gcc
to provide me with a warning if I accidentally forget to propagate the error (i.e. when I forget to use the return integer).
Example
Consider this very simple example test.c
:
// header
int test ( int a );
// function
int test ( int a )
{
if ( a<0 ) return 1;
return 0;
}
// main program
int main ( void )
{
int a = -10;
test(a);
return 0;
}
Expected behavior
$ gcc -Wunused-result main.c
Warning: main.c:19 ... unused return ...
or alternatively using Wall
or Wextra
or another option.
Needless to say, my compiler does not provide the warning with any of these options. One of my mistakes already took me frustratingly long to find...