Mail Archives: djgpp/1997/01/09/10:49:12
From: wildthing AT value DOT net (Wild Thing)
Date: Sat, 04 Jan 1997 00:09:21 GMT
Whenever I prototype a function in DJGPP, RHIDE tells gives me a
warning when I try to compile the program.
for example:
// my c program
#include <stdio.h>
#include <conio.h>
newFunction(int i); // prototype
Your prototype is incorrect as is the function declaration. This mixes K&R and ANSI declaration styles. The proper way to declare a function that returns an int is:
int newFunction(int i); // prototype
main()
{
int i = 5;
clrscr();
printf("blah blah");
newFunction(i);
return 0;
}
newFunction(int i)
This should be:
int newFunction(int i)
{
printf(" %d", i);
return 0;
}
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?
By the way main() should also be explicitely declared to be:
int main( void )
--OR--
int main( int argc, char **argv )
--
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com
A proverb is no proverb to you 'till life has illustrated it. -- John Keats
- Raw text -