----- Original Message -----
From: "Matthew Woehlke" <mw_triad@xxxxxxxxxxxxxxxxxxxxx>
To: <gcc-help@xxxxxxxxxxx>
Sent: Thursday, April 12, 2007 12:31 PM
Subject: Re: incompatible function declaration
Michael wrote:
gcc behaves differently for following program:
void foo2();
int main() {
extern void foo(void);
foo();
foo2();
return 0;
}
void foo2() {
foo();
}
compilation command: gcc -c t1.c
result:
1. gcc 3.2.2 compiles successfully.
2. gcc 4.0.3 gives following message:
t1.c: In function 'foo2':
t1.c:10: error: incompatible implicit declaration of function 'foo'
t1.c:3: error: previous implicit declaration of 'foo' was here
question:
which one is more correct ? Is the error message too severe ?
I would say 4.0.3 is right... you made the declaration in a local
scope so it does not apply to foo2(). When foo2() tries to call foo(),
the default implicit prototype is 'int foo()', which is incompatible
with the previous declaration as the error states.
I am fine with both behaviors. The more important issue is that the
change in 4.0.3 might break existing code because of the error message.
Anyway, just let you guys know about it.
Mike
--
Matthew
GDRLaH - Grin, Duck, and Run Like a Hippo! :-)