From: Arend-Jan Westhoff <jpmcyafvmhsl@spammotel.com>
To: "Michiel De Hoon" <mdehoon@c2b2.columbia.edu>,cygwin@cygwin.com
Subject: Re: _kbhit
Date: Thu, 16 Feb 2006 01:48:00 -0000 [thread overview]
Message-ID: <20060216011405.9CC6E2681@dot.warande.net> (raw)
In-Reply-To: <6CA15ADD82E5724F88CB53D50E61C9AE9ECE5E@cgcmail.cgc.cpmc.co lumbia.edu>
[-- Attachment #1: Type: text/plain, Size: 1363 bytes --]
At 18:58 2006-02-10 -0500, Michiel de Hoon wrote:
>> On Sun, Feb 05, 2006 at 01:17:33PM -0500, Michiel De Hoon wrote:
>> >For one of my software projects, I need the _kbhit function to check the
>> >console for keyboard input. While this function is present in msvcrt.dll,
>it
>> >is missing from cygwin1.dll, so I started writing this function myself
>(I'm
>> >hoping to contribute it to Cygwin if it works well).
>>
>> I really appreciate the sentiment of submitting code but _kbhit is not a
>> linux function (or <echo on>POSIX, POSIX, POSIX...</echo off>) so it
>> really isn't a candidate for inclusion in the Cygwin DLL.
>>=20
>> cgf
>>
>Even though _kbhit is not a POSIX function, I think a valid argument can be
>made to include it in Cygwin anyway.
>
>First, some Cygwin programs will need this function to be able to interact
>with the Windows OS. Second, as the Cygwin DLL is a replacement for msvcrt
>(and msvcrt.dll and cygwin1.dll cannot be used together), [snip]
I cannot confirm your assertion that msvcrt.dll and cygwin1.dll cannot be
used
together. If I compile the attached (almost C) file that dynamically links to
msvcrt.dll using Cygwin:
gcc -o kbhit.exe kbhit.cpp
it compiles, links and works (on CMD and bash on CMD but not on rxvt; as
stated elsewhere in this thread the Microsoft _kbhit is not very good).
HTH,
Arend-Jan Westhoff.
[-- Attachment #2: kbhit.cpp --]
[-- Type: text/plain, Size: 459 bytes --]
#include <stdio.h>
#include <windows.h>
extern "C" {
typedef int (*int_function_void_t)(void);
HINSTANCE gimmeMSVCRT() {
static HINSTANCE retval = LoadLibrary("MSVCRT.DLL");
return retval;
}
int _kbhit(void) {
static int_function_void_t f = (int_function_void_t) GetProcAddress(gimmeMSVCRT(), "_kbhit");
return f();
}
} // extern "C"
int main() {
printf("Hit me!"); fflush(stdout);
while(!_kbhit())
;
printf("\nOuch!!\n");
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 218 bytes --]
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
next parent reply other threads:[~2006-02-16 1:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <6CA15ADD82E5724F88CB53D50E61C9AE9ECE5E@cgcmail.cgc.cpmc.co lumbia.edu>
2006-02-16 1:48 ` Arend-Jan Westhoff [this message]
2006-02-16 7:17 ` _kbhit Gary R. Van Sickle
2006-02-17 20:49 ` _kbhit Shankar Unni
2006-02-17 20:51 ` _kbhit Christopher Faylor
2006-02-18 21:30 ` _kbhit Gary R. Van Sickle
2006-02-13 17:18 _kbhit Michiel De Hoon
2006-02-13 18:12 ` _kbhit Christopher Faylor
2006-02-13 18:50 ` _kbhit Dave Korn
2006-02-14 4:00 ` _kbhit skaller
-- strict thread matches above, loose matches on Subject: below --
2006-02-11 0:19 _kbhit Michiel De Hoon
2006-02-11 5:11 ` _kbhit Gary R. Van Sickle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060216011405.9CC6E2681@dot.warande.net \
--to=jpmcyafvmhsl@spammotel.com \
--cc=cygwin@cygwin.com \
--cc=mdehoon@c2b2.columbia.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).