From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: compiler troubles Date: Fri, 04 Oct 1996 18:53:28 -0700 Organization: Three pounds of chaos and a pinch of salt Lines: 67 Message-ID: <3255BF98.7D03@cs.com> References: <3 DOT 0b26 DOT 32 DOT 19961004162450 DOT 00685b9c AT cis DOT cisnet DOT com> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp211.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Dr Eclipz To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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. | ---------------------------------------------------------------------