public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Dave Korn" <dave.korn@artimi.com>
To: <cygwin@cygwin.com>
Subject: RE: _kbhit
Date: Mon, 13 Feb 2006 18:50:00 -0000	[thread overview]
Message-ID: <010301c630c8$fb06ff10$a501a8c0@CAM.ARTIMI.COM> (raw)
In-Reply-To: <6CA15ADD82E5724F88CB53D50E61C9AE9ECE5F@cgcmail.cgc.cpmc.columbia.edu>

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/

  parent reply	other threads:[~2006-02-13 18:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-13 17:18 _kbhit Michiel De Hoon
2006-02-13 18:12 ` _kbhit Christopher Faylor
2006-02-13 18:50 ` Dave Korn [this message]
2006-02-14  4:00   ` _kbhit skaller
     [not found] <6CA15ADD82E5724F88CB53D50E61C9AE9ECE5E@cgcmail.cgc.cpmc.co  lumbia.edu>
2006-02-16  1:48 ` _kbhit Arend-Jan Westhoff
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
  -- 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='010301c630c8$fb06ff10$a501a8c0@CAM.ARTIMI.COM' \
    --to=dave.korn@artimi.com \
    --cc=cygwin@cygwin.com \
    /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).