This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: _kbhit


On 13 February 2006 17:10, Michiel De Hoon wrote:

> Gary R. Van Sickle wrote:
>>> First, some Cygwin programs will need _kbhit to be
>>> able to interact with the Windows OS.
>> 
>> That's simply not true.  They may *want* it so that they can interact with
>> cmd.exe, in which case they're not a "Cygwin program".
> 
> If:
> 1) A program needs to run a Windows message loop;

-  Then it's not a POSIX program.

> 2) This message loop should be exited when user input is available on stdin;

-  Then if it's running a windows message loop, it should be looking for
WM_KEYDOWN.  (_kbhit is a remnant from the late '80s DOS 3.x int 21h call
interface; I don't know if it's even guaranteeed to play nicely with windows
message queues in any case, is it?  It certainly requires a console to be
available at the very least...)

-  And if it's trying to be a POSIX program, it should use the POSIX way of
doing that (cf. select/ncurses/footnote[*] qv).

> 3) The program needs to link to cygwin1.dll;
> then it is a Cygwin program that needs _kbhit (either present in the DLL or
> implemented by myself using select()), isn't it?

  No.

  It's a MinGW program that has been compiled for the wrong environment.





  The key is in the word "needs" to link to cygwin1.dll.

  Why would any app (in general, and yours in particular) /need/ to link to
cygwin1.dll?  The only reason is for the POSIX/Unix/Linux compatibility it
provides, because that is _all_ that cygwin1.dll does.

  You will never want to write a fullly POSIX/Unix/Linux-compatible
application that contains a Windows message loop, because then it's not a
POSIX/Unix/Linux-compatible application, by definition.

  If you're writing what is fundamentally a Windows program, and just want a
few library functions to provide you with posix-alike functionality, that is
/exactly/ the definition of MinGW.  Use it instead.

  If you want a full POSIX/Unix/Linux-compatible environment that runs on
windows, you want Cygwin, but then you don't want to write windows message
loops, or your code won't be POSIX/Unix/Linux-compatible.

 
    cheers,
      DaveK

[*] - Ok.  Here ya go: "_kbhit() for Linux".
http://www.flipcode.org/cgi-bin/fcarticles.cgi?show=64166
Considering that this is hit #1 on google when you enter the term "_kbhit", it
seems blatantly clear that you haven't made even a token effort to STFW.
-- 
Can't think of a witty .sigline today....


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]