Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 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 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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 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 > > > #include > > > > > > int main(void) > > > { > > > int c; > > > c = getch(); > > > while (c != 27) //27 = esc > > > { > > > cout<<"pressed :"< > > 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