delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com> |
List-Archive: | <http://sourceware.cygnus.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT sourceware DOT cygnus DOT com> |
List-Help: | <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs> |
Sender: | cygwin-owner AT sourceware DOT cygnus DOT com |
Delivered-To: | mailing list cygwin AT sourceware DOT cygnus DOT com |
Message-ID: | <37E0BCC1.859D753E@solfin.com> |
Date: | Thu, 16 Sep 1999 11:47:46 +0200 |
From: | Gabriel Galibourg <gabriel AT solfin DOT com> |
Reply-To: | gabriel AT solfin DOT com |
Organization: | Solfin Limited |
X-Mailer: | Mozilla 4.61 [en] (WinNT; I) |
X-Accept-Language: | en,en-GB,en-US,fr,fr-BE,fr-CA,fr-CH |
MIME-Version: | 1.0 |
To: | Daniel Harry Hawson <u7dhh AT dcs DOT shef DOT ac DOT uk> |
CC: | cygwin AT sourceware DOT cygnus DOT com |
Subject: | Re: Won't compile the simplest of progs. |
References: | <199909151131 DOT MAA02157 AT cedar DOT dcs DOT shef DOT ac DOT uk> |
Yes cygwin (well really gcc) compiles C and C++ code, altough I prefer to use gcc when compiling C code and g++ when compiling C++ code (helps the linker get it right). The problem with your code is that you are using a windows function (getch()) which does not exist in cygwin (or Unix). The 'proper' Unix way to get simple character input would be to put your terminal in non-canonical mode (stty -icanon min 1 time 0), you can do this within a C/C++ program by using ioctl() (but I've never done it under cygwin so I ignore if it works). So to keep the story short, to get your program to work do the following: 1) remove the #include <conio.h> since cygwin doesn't know about it - you could put the full path to it (in your msdev directories) - but I don't think that would help much 2) change your call to getch() to _getch() - which is the 'real' library function (getch() is merely a #define to it) 3) compile the following way: g++ -o Progs/key.exe Progs/keypress.cpp -lmsvcrt You need to link with msvcrt which is where _getch() is defined. You'll also get a warning about the implicit declaration of _getch(), you can always clean this up later by creating you own conio.h with the good stuff in it. The resulting program works fine under a 'normal' command prompt (cmd.exe) but does not work very well under the cygwin bash . Gabriel. > Daniel Harry Hawson wrote: > > > I have a 'Progs' folder in my 'cygwin-b20' folder. > > In 'Progs', I tried to compile a C++ file called 'Keypress.cpp'. > > > > > BASH.EXE-2.02$ gcc -o Progs/key.exe Progs/keypress.cpp > > > Progs/keypress.cpp:1: conio.h: No such file or directory > > > BASH.EXE-2.02$ > > > > What am I doing wrong? > > > > Here is the contents of 'Keypress.cpp' - > > > > > #include <conio.h> > > > #include <iostream.h> > > > > > > int main(void) > > > { > > > int c; > > > c = getch(); > > > while (c != 27) //27 = esc > > > { > > > cout<<"pressed :"<<c<<'\n'; > > > c = getch(); > > > } > > > return 0; > > > } > > > > Will CygWin work with C++ or just C code? > > How can I get this to work? > > > > Thanks. > > > > Dan > > u7dhh AT dcs DOT shef DOT ac DOT uk > > > > -- > > Want to unsubscribe from this list? > > Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |