delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/01/12/06:01:12

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW
X-Spam-Check-By: sourceware.org
Message-ID: <4F0EBD46.1050406@gmail.com>
Date: Thu, 12 Jan 2012 11:00:22 +0000
From: Dave Korn <dave DOT korn DOT cygwin AT gmail DOT com>
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Can't get includes untangled
References: <4F0C8EDD DOT 6070003 AT gmail DOT com> <4F0C90A9 DOT 5000306 AT cygwin DOT com>
In-Reply-To: <4F0C90A9.5000306@cygwin.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 10/01/2012 19:25, Larry Hall (Cygwin) wrote:
> On 1/10/2012 2:17 PM, Jarome wrote:
>> When I make my Windows 7 cygwin project, I keep getting
>> In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../
>> include/w32api/windows.h:98:0,
>>                   from src/tkfPusher.c:23:
>> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/
>> winsock2.h:103:2: warning: #warning "fd_set and associated macros have
>> been defined in sys/types.      This may cause runtime problems with
>> W32 sockets"
>>
>> Everything works in MinGW.
> 
> Don't include windows files for Cygwin.  Think of Cygwin as a UNIX/Linux
> environment.  Anything you wouldn't include there shouldn't be included
> when building for Cygwin.

  That's a simple rule to follow that will avoid some problems, but I thought
mixed-mode coding wasn't actually prohibited and we don't actually go out of
our way to break it - hence the existence of __USE_W32_SOCKETS in the first
place, no?

  To Jarome:

> I tried adding the #define __USE_W32_SOCKETS to
> try and fix this because if defined, it should ignore the fd things in
> types.h, but no success.

  The problem is that you're not defining it early enough:

> #define GPC_CYGWIN
> #define GPC_WIN
> #include <stdio.h>
> #include <errno.h>
> #include <dirent.h>   // This includes sys/types.h

  Yes, it does, so __USE_W32_SOCKETS should already have been defined by that
point or it's too late; both winsock2.h *and* sys/types.h have to be #included
while it is already in effect (they both contain #ifdefs that test it).  And
in fact, stdio.h also indirectly include sys/types.h, so the simple answer is
just to define __USE_W32_SOCKETS right at the top alongside the other defines
before you even include the first file.

    cheers,
      DaveK


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019