public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
From: Charles Wilson <cygwin@cwilson.fastmail.fm>
To: cygwin-xfree@cygwin.com
Subject: Re: Built XWin on mingw - with patches
Date: Wed, 09 Nov 2011 19:11:00 -0000	[thread overview]
Message-ID: <4EBAD044.50306@cwilson.fastmail.fm> (raw)
In-Reply-To: <4EBACA74.3090704@dronecode.org.uk>

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 <windows.h>
#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 <jpeg.h> 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/


  reply	other threads:[~2011-11-09 19:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-01 20:40 Ryan Pavlik
2011-11-03 19:18 ` Jon TURNEY
2011-11-04 23:39   ` Ryan Pavlik
2011-11-07 18:10     ` Jon TURNEY
2011-11-07 19:36       ` Charles Wilson
2011-11-09 18:46         ` Jon TURNEY
2011-11-09 19:11           ` Charles Wilson [this message]
     [not found]             ` <CABMFTE8wrNqbNLX+jmd7WcxT-xqfxYctB-ZgmxfwBg38_g5xmw@mail.gmail.com>
2011-11-10 22:58               ` Charles Wilson
2011-11-10 16:50       ` Ryan Pavlik
2011-11-22  2:55         ` SeongNam Oh
2012-01-09 19:31         ` Jon TURNEY

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=4EBAD044.50306@cwilson.fastmail.fm \
    --to=cygwin@cwilson.fastmail.fm \
    --cc=cygwin-xfree@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).