From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1725 invoked by alias); 9 Nov 2011 19:11:29 -0000 Received: (qmail 1717 invoked by uid 22791); 9 Nov 2011 19:11:28 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from out2.smtp.messagingengine.com (HELO out2.smtp.messagingengine.com) (66.111.4.26) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Nov 2011 19:10:57 +0000 Received: from compute5.internal (compute5.nyi.mail.srv.osa [10.202.2.45]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 10F2620CA0 for ; Wed, 9 Nov 2011 14:10:56 -0500 (EST) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute5.internal (MEProxy); Wed, 09 Nov 2011 14:10:56 -0500 Received: from [158.147.67.90] (158-147-67-90.harris.com [158.147.67.90]) by mail.messagingengine.com (Postfix) with ESMTPSA id BE0624824B1; Wed, 9 Nov 2011 14:10:55 -0500 (EST) Message-ID: <4EBAD044.50306@cwilson.fastmail.fm> Date: Wed, 09 Nov 2011 19:11:00 -0000 From: Charles Wilson Reply-To: Charles Wilson User-Agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: cygwin-xfree@cygwin.com Subject: Re: Built XWin on mingw - with patches References: <4EB2E8FE.6020305@dronecode.org.uk> <4EB81EF8.5060107@dronecode.org.uk> <4EB83346.8090007@cwilson.fastmail.fm> <4EBACA74.3090704@dronecode.org.uk> In-Reply-To: <4EBACA74.3090704@dronecode.org.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-xfree-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-xfree-owner@cygwin.com Reply-To: cygwin-xfree@cygwin.com Mail-Followup-To: cygwin-xfree@cygwin.com X-SW-Source: 2011-11/txt/msg00018.txt.bz2 On 11/9/2011 1:46 PM, Jon TURNEY wrote: > On 07/11/2011 19:36, Charles Wilson wrote: >> But this isn't true if you ever #include any of the w32api headers. Then >> you get WIN32 defined, even on cygwin... > > True. I guess what I meant to say is that there isn't any compiler which > defines both WIN32 and CYGWIN (I hope :-)). > > Any portable code which includes w32api headers before checking if WIN32 > is defined isn't going to be very portable :-) But it's perfectly portable to check for __CYGWIN__ (or, for that matter, __MINGW32__) instead of WIN32 before #including w32api headers, because you know that the windows API will be available in those cases as well. The difference is, IF you do this (perfectly fine, legal, and portable) thing: #if defined(WIN32) || defined(__CYGWIN__) # include #endif then you can no longer rely on #if defined(WIN32) ...stuff that applies only for truly "native" windows (e.g. ...msvc or mingw), but not cygwin #endif even though both hunks above are legal and make perfect sense *in isolation*. The problem occurs when both hunks are present in the same translation unit -- and that's not always under your control. What if libjpeg's header does the first hunk (it doesn't, but assume that it does for argument's sake), and your project's headers only do the second? You *think* you're safe in assuming that WIN32 == !__CYGWIN__, but...#include breaks all your assumptions. But jpeg.h *did nothing wrong*. It's better to be explicit. -- Chuck -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://x.cygwin.com/docs/ FAQ: http://x.cygwin.com/docs/faq/