www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/03/21:52:31

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: newbie question
Date: Fri, 03 Jan 1997 18:55:15 -0800
Organization: Two pounds of chaos and a pinch of salt
Lines: 43
Message-ID: <32CDC693.7051@cs.com>
References: <32cd9e4f DOT 6800703 AT news DOT value DOT net>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp211.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


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