X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Thu, 12 Mar 2009 16:26:59 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: IOCTL using Message-ID: <20090312152659.GA2364@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20090312083353 DOT GB14431 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-02-20) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: 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 On Mar 12 14:52, Bert wrote: > Corinna Vinschen cygwin.com> writes: > > On Mar 11 22:57, Bert wrote: > > > I hope I'm doing something really dumb, any tips? > > > > Yes. You're mixing POSIX calls with Windows defines. That's a no-no. > > When you're in Rome, talk like the Romans do. > > > > Corinna > > > > Many thanks Corinna. If I understand you correctly, "talk like the Romans" means > "just make everything pure POSIX calls", right? Right. > Secondly, if that's the case, what would the purpose of the Windows defines be? > (Apart from confusing simple folks like me :) Put another way, if I want to use > those defines (i.e. flee Rome and settle in Babylon), what version of ioctl > should I call and what libs should I link in? The native Windows headers provide you with a means to use native Windows calls from a Cygwin application. In your case, either talk POSIX with the com interface open("/dev/com4"); // Btw. "/dev/ttyS3" is preferred ioctl(POSIX_IOCTL_CODE); close; or talk Windows CreateFile("COM4:", ...); DeviceIoControl(WIN32_IOCTL_CODE); CloseHandle; but don't mix them. You will do yourself no good. Given that the Cygwin DLL has to keep track of state information, that should be clear. If you open a file with a POSIX call, stick to POSIX for handling the file until you close it. The Cygwin DLL will do the translations. If you need direct control for some reason, open the file with a Windows call and stick to Windows calls until you close the file. > Thirdly, and I'm probably pushing it now, if you have some favorite references > to read on the above dichotomy? I'd appreciate the pointer. Or is it *pointer? The dichotomy is mostely in your mind. As soon as you realize that Cygwin is a POSIX emulation layer on top of Windows, the above should be quite clear. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- 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/