Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting compilation warnings for non-prototype declarations

In C, function declarations can be prototype or non-prototype declarations. For example, consider the following minimal program:

int foo (); /* non-prototype declaration */

int bar (void); /* prototype declaration */

int main (int argc, char **argv)
{
  return 0;
}

Although in C99 non-prototype declarations are obsolete, I cannot get GCC to complain about them. For example, compiling the above program with GCC and all errors enabled just succeeds:

$ gcc -std=c99 -pedantic -Werror -Wall test.c
$

Is there any way to persuade GCC to emit warnings for function declarations that aren't prototypes?

(Question inspired by an answer by Keith Thompson.)

like image 811
Peter T.B. Brett Avatar asked Sep 13 '26 13:09

Peter T.B. Brett


1 Answers

I think the option you are looking for is -Wstrict-prototypes

like image 83
celtschk Avatar answered Sep 16 '26 03:09

celtschk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!