Mail Archives: djgpp/1996/10/04/19:35:53
Dr Eclipz wrote:
>
> the problem i get is when i try to compile a program i'm working on. i
> changed the type of several functions from 'int' to 'void' and some
> compiler warnings surfaced. for a while, djgpp compiled the program and
> after the warnings said 'no errors'. now it's gotten to the point where it
> just doesn't finish compiling at all. is there some way to
> make the compiler stop keeping track of me changing types or to make it
> shut up with those errors? thanks for any help you can provide! (read on
> for my eviron.lst and other information)
>
> -----------------------------------------------------------------------------
>
> djgpp gives me variations of the following warnings:
>
> Warning: previous implicit declaration of '[function name]'
> Warning: '[function name]' was previously implicitly declared to return 'int'
> Warning: type mismatch with previous implicit declaration
> Warning: type mismatch with previous external decl
These are serious warnings that you should pay attention to! You may
have changed the function definitions, but you did not change the
prototypes that you declared earlier (in a header file or at the top of
your program?) The prototypes are declaring your functions to return
int and you then give a definition which has them return void. This
must be fixed!
Second, you are getting 'implicit declaration' warnings because you are
using functions without first declaring prototypes for them. This is
_required_ under ANSI C and you should not simply ignore the warnings.
The other problem with doing this is that an implicitly declared
function is assumed to return 'int', not 'void', and thus this
declaration conflicts with your subsequent definition of the same
function.
Consider these examples:
int main( void )
{
...
/* here, myproc is _implicitly declared_ to return int */
myproc( foo, bar );
...
}
/* here, you declare it void, which conflicts with the previous
definition */
void myproc( int foo, int bar )
{
...
}
It should be possible, FYI, to turn off most of those warnings by not
using '-Wall' when you compile, but this can lead to so many kinds of
serious errors that I STRONGLY encourage you to fix the problems with
your code instead.
To mangle a metaphor, it's far easier to repair the dike first than to
keep plugging up the holes. Sooner or later you run out of fingers.
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com |
| * Proud user of DJGPP! * | http://www.cs.com/fighteer |
| ObJoke: If Bill Gates were a robber, not only would he |
| shoot you, but he'd send you a bill for the bullets. |
---------------------------------------------------------------------
- Raw text -