delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/05/11:51:56

Date: Thu, 5 Oct 2000 17:49:28 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Paulo J. Matos aka PDestroy" <pdestroy AT netcabo DOT pt>
cc: djgpp AT delorie DOT com
Subject: Re: Strange error
In-Reply-To: <8ri3am$l53$1@venus.telepac.pt>
Message-ID: <Pine.SUN.3.91.1001005174610.8364C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 5 Oct 2000, Paulo J. Matos aka PDestroy wrote:

> void wait_u(void) {
>  getkey(NULL);
> }
> 
> Waits for the user to press any key. I've implemented in a program I made
> some months ago. Now I copy-pasted to my new program I'm doing now and the
> compiler says:setup.c: In function `wait_u':
> setup.c:124: too many arguments to function `getkey'
> 
> How strange!!! On the other program it compiled correcly...

Let me guess: the program which doesn't compile #include's the header 
pc.h, while the one which compiles doesn't include it.

pc.h declares a prototype of the function getkey(), which tells the 
compiler that it doesn't accept any arguments.  So the compiler complains 
when you call it with an argument of NULL.  If you don't make the 
prototype visible to the compiler, it won't complain (but your program 
will then have a bug that waits to bite you).

That's why you are well advised to always include the appropriate 
headers for the library functions you call.

- Raw text -


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