Mail Archives: djgpp/1997/01/03/21:52:31
Wild Thing wrote:
>
> sorry about the bad example, i'm just learning c and had to think of
> it off the top of my head.. anyhow, when i try to compile it under
> rhide with djgppv2 it says "warning: newFunction() has no data type or
> something or other".. but the program works fine if i remove the
> prototype at the top.. is this normal?
Yes, and it's because you are declaring your functions with default
return types. This is a very bad; even unsanitary habit to get into, so
it's best you break it ASAP. Here's code that doesn't give any
warnings, even with -Wall (which I strongly suggest you use). The extra
spacing and formatting is my own; feel free to adopt this style or any
other you choose. :)
// my c program
#include <stdio.h>
#include <conio.h>
int newFunction( int i ); // prototype
int main( void )
{
int i = 5;
clrscr( );
printf( "blah blah" );
newFunction( i );
return 0;
}
int newFunction( int i )
{
printf( " %d", i );
return 0;
}
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com |
| God's final message to His Creation: | http://www.cs.com/fighteer |
| "We apologize for the inconvenience."| Fight against proprietary |
| - Douglas Adams | software - support the FSF!|
---------------------------------------------------------------------
- Raw text -