Mail Archives: djgpp/2000/10/05/11:51:56
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 -