Article View: comp.std.c
Article #2117Re: Static function prototypes and definitions
From: Paul Eggert
Date: Mon, 12 Oct 1992 22:03
Date: Mon, 12 Oct 1992 22:03
32 lines
1469 bytes
1469 bytes
lmiller@aero.org (Lawrence H. Miller) writes:
>If I have a static function defined in a file, must the
>prototype also have the word static? My reading of the
>standard is that the word static is forbidden in block
>scope declarations, but gnu C requires it.
I can't reproduce the problem that you describe. Given the program
void f(void) { static void g(void); g(); }
static void g(void) {}
`gcc -ansi -pedantic' (GCC 2.2.2) issues a diagnostic, as required by
the C standard:
t.c: In function `f':
t.c:1: warning: invalid storage class for function `g'
The proper way to write this is:
static void g(void);
void f(void) { g(); }
static void g(void) {}
It's not necessarily a good idea to use GCC to check for conformance.
The GCC manual says:
Some users try to use `-pedantic' to check programs for strict ANSI
C conformance. They soon find that it does not do quite what they
want: it finds some non-ANSI practices, but not all--only those
for which ANSI C *requires* a diagnostic.
Technical Details
Message-ID:
<bjEsPb0L@twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggertReferences:
<1bcn2mINN680@news.aero.org>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert From: eggert@twinsun.com (Paul Eggert) Subject: Re: Static function prototypes and definitions Message-ID: <bjEsPb0L@twinsun.com> Sender: usenet@twinsun.com Nntp-Posting-Host: farside Organization: Twin Sun, Inc References: <1bcn2mINN680@news.aero.org> Date: Mon, 12 Oct 1992 22:03:51 GMT Lines: 32