Bug 11246 - warning: no previous prototype for foobar_func ()
Summary: warning: no previous prototype for foobar_func ()
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.3
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-18 22:42 UTC by saptor
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description saptor 2003-06-18 22:42:34 UTC
Compile with -Wmissing-prototypes turned on.  Code:

int foo();

int main()
{
   foo();
   return 0;
}

int foo()
{
   return 0;
}

Produces this output:
$ gcc -Wmissing-prototypes foo.c
foo.c:10: warning: no previous prototype for `foo'

I've tested this behaviour in GCC 2.95, 3.2.3, and 3.3.   Changing the prototype
to foo(void) makes the warning go away.

Someone reported this bug before but it was closed due to inactivity:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7749
Comment 1 Wolfgang Bangerth 2003-06-18 23:14:01 UTC
Confirmed. I'm not a specialist in old-times C, but IIRC 
  void f();
simply defined the existence of f(), but not its argument list. For that,
you really needed
  void f(void);

I don't know whether this behavior is changed in later standards, but
at least passing -std=c89 or -std=c99 doesn't change anything for this
warning.

W.
Comment 2 Eric Botcazou 2003-06-19 07:49:44 UTC
int foo(); is not a prototype because it provides no information about the
number or types of the parameters.