Mail Archives: djgpp/2000/07/07/07:54:28
From: | Chris Mears <cmears AT bigpond DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: getch() mysteriously defined
|
Organization: | only if absoultely necessary
|
Message-ID: | <8ubbmsk17t4djl7cp8mput3su30k9uebk5@4ax.com>
|
References: | <8k470e$262$1 AT plato DOT wadham DOT ox DOT ac DOT uk>
|
X-Newsreader: | Forte Agent 1.8/32.548
|
MIME-Version: | 1.0
|
Lines: | 39
|
Date: | Fri, 07 Jul 2000 20:26:51 +1000
|
NNTP-Posting-Host: | 203.54.70.161
|
X-Trace: | newsfeeds.bigpond.com 962965095 203.54.70.161 (Fri, 07 Jul 2000 20:18:15 EST)
|
NNTP-Posting-Date: | Fri, 07 Jul 2000 20:18:15 EST
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
On 7 Jul 2000 10:13:50 +0100, that hoopy frood J-P scribbled the
following:
>Does anyone know why this program works "as-is" i.e. with no extra
>pre-compiler #include lines:
>
>/*---------------------------*/
>
>int main()
>{
> getch();
>}
>
>/*---------------------------*/
>
>If getch() is declared in conio.h (I think it's in grx20.h as part of the
>GRX library, too), then how on earth can gcc under rhide compile the
>program, and run it, and return the code of the keypress, without some
>header file or other?
Well, gcc *does* complain:
proto.c: In function `main':
proto.c:3: warning: implicit declaration of function `getch'
proto.c:4: warning: control reaches end of non-void function
In C, it was legal to call a function without a prototype, or even a
declaration(?). If a declaration is omitted, the compiler assumes
that the function has a return value of type int and takes a fixed
number of arguments.
The new standard for C disallows this. C++ has never allowed it.
getch() is still called because it is part of libc, and libc is linked
with the executable.
--
Chris Mears
ICQ: 36697123
- Raw text -