On 18 February 2013 13:02, Comeau At9Fans <comeauat9f...@gmail.com> wrote:

> seems to be doing is setting up allowing the call to compile and once that
> is satisfied then the subsequent definition "has" to match it, as perhaps a
> way to do type punning.


No, the compiler is simply applying scope rules. Without that inner
declaration explicitly overriding the outer declaration--whether static or
extern is used--
it will not compile (eg, if you put "static void fn(Outer*);" or "extern
void fn(Outer*);" and remove static from fn in the file scope).

The behaviour is undefined in ANSI C if two declarations that refer to the
same object or function do not have compatible types
(normally, you're protected by another rule that you can't have
incompatible declarations *in the same scope*).

ANSI C does, however, forbid the inner static declaration (which surprised
me)
"The declaration of an identifier for a function that has block scope shall
have no explicit storage-class specifier other than extern." (6.7.1)

Reply via email to