From: Mihai Moise Newsgroups: comp.os.msdos.djgpp Subject: Re: compiler troubles Date: Wed, 09 Oct 1996 12:30:22 -0400 Organization: Universite Laval Lines: 79 Message-ID: <325BD31E.41C67EA6@ift.ulaval.ca> References: <3 DOT 0b26 DOT 32 DOT 19961004162450 DOT 00685b9c AT cis DOT cisnet DOT com> NNTP-Posting-Host: britten.ift.ulaval.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Dr Eclipz wrote: > > 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 You should NEVER implicitly declare a function. Sometimes the code will be good, but other times it will play havoc. Here is what I am talking about: int main ( void ) { my_function(); } void my_function ( void ) { ... } Will cause the first two warnings. When a function is used before it is declared, GCC expects it to return an int by default. Three approaches will solve the problem, but only the last two are good. 1: int my_function ( void ) { ... } 2: void my_function ( void ); int main ( void ) { my_function(); } 3: void my_function ( void ) { ... } int main( void ) { my_function(); } Yesterday, I tried to compile a plug-in for GIMP which did implicit type conversion ( finally got it to compile ), so for now I believe that all those who do it should be hanged. This is what I am talking about: u_char* function() { ... } main ( void ) { int a = function(); } You have been warned. > Warning: type mismatch with previous external decl > > something like: extern int my_var; char my_var; should generate this warning. Good luck! Mihai