X-Spam-Check-By: sourceware.org X-Sender: @ (Unverified) Date: Thu, 16 Feb 2006 02:13:55 +0100 To: "Michiel De Hoon" , cygwin AT cygwin DOT com From: Arend-Jan Westhoff Subject: Re: _kbhit In-Reply-To: <6CA15ADD82E5724F88CB53D50E61C9AE9ECE5E@cgcmail.cgc.cpmc.co lumbia.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=====================_1140048835==_" Message-Id: <20060216011405.9CC6E2681@dot.warande.net> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --=====================_1140048835==_ Content-Type: text/plain; charset="us-ascii" 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 POSIX, POSIX, POSIX...) 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. --=====================_1140048835==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="kbhit.cpp" #include #include 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; } --=====================_1140048835==_ Content-Type: text/plain; charset=us-ascii -- 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/ --=====================_1140048835==_--