delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/09/10:49:12

From: kagel AT quasar DOT bloomberg DOT com
Date: Thu, 9 Jan 1997 10:09:02 -0500
Message-Id: <9701091509.AA13638@quasar.bloomberg.com >
To: wildthing AT value DOT net
Cc: djgpp AT delorie DOT com
In-Reply-To: <32cd9e4f.6800703@news.value.net> (wildthing@value.net)
Subject: Re: newbie question
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019