delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/05/30/16:04:06

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=Y1VBfuPGcbRO7Bw+y6r97OUUoObURzSDHT3oW/3AEVvCx1/LejUGp
Bw68jIC+ZEFxt8DzWBpBip2yuR1E4azJ36JbMqb61LgKuHE0EFu3zTl/YVPAg6m5
o47/s1ghPnkf4M3P7Vt2wVgZ7er5Ni24YqZZYMhjtR6GBIA9CauxdQ=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=763vq+XSuRuhehcOQo8yyCEYzH8=; b=I1Dej43uUf5z2uvUKvJ2VcopwJ0d
bc2Lm/YGParxYcfBAkL0vc5AT8gZqjhjqxdRR5uMqZzaAU96ldU1fy7hBSB0Yx2r
7pzIpp0CplKUorUerpxLCF/vzrDa2mOqEsmPmv9wxnFeOYERHkGuAHJ6l/xnAkqd
TQ3cv9l4irKN7uM=
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
X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1
Date: Thu, 30 May 2013 22:03:44 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: bug in <sys/un.h>
Message-ID: <20130530200344.GA23141@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <51A78E70 DOT 1010600 AT redhat DOT com>
MIME-Version: 1.0
In-Reply-To: <51A78E70.1010600@redhat.com>
User-Agent: Mutt/1.5.21 (2010-09-15)

On May 30 11:37, Eric Blake wrote:
> STC - this program does nothing useful when executed; it merely exists
> to show a compilation problem extracted from a larger program:
> 
> $ cat foo.c
> #ifdef WORKAROUND
> # include <sys/socket.h>
> #endif
> #include <sys/un.h>
> #include <sys/socket.h>
> int main(void) {
>   const struct msghdr msg;
>   return sendmsg(0, &msg, 0);
> }
> $ gcc -o foo -Wall foo.c
> foo.c: In function 'main':
> foo.c:9:5: warning: passing argument 2 of 'sendmsg' from incompatible
> pointer type
> /usr/include/sys/socket.h:42:11: note: expected 'const struct msghdr *'
> but argument is of type 'const struct msghdr *'
> $ gcc -o foo -Wall foo.c -DWORKAROUND
> $
> 
> Gcc has a less-than-stellar error message (expect type X but have type
> X); it could do a better job about pointing out that it is complaining
> about two different 'type X' declarations, and where they come from.
> But the root cause is that if <sys/un.h> is included first, then the use
> of 'struct msghdr' applied in the declaration of sendmsg() is somehow
> scoped incorrectly (local to the declaration rather than the global
> type), so that the compiler really is complaining about two different
> incompatible 'struct msghdr' layouts.  I'm not quite sure what the fix
> should be, [...]

Try this:

Index: cygwin/if.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/if.h,v
retrieving revision 1.11
diff -u -p -r1.11 if.h
--- cygwin/if.h	21 Jan 2013 04:38:30 -0000	1.11
+++ cygwin/if.h	30 May 2013 20:02:56 -0000
@@ -16,7 +16,7 @@ extern "C" {
 #endif /* __cplusplus */
 
 #include <sys/types.h>
-#include <sys/socket.h>
+#include <cygwin/socket.h>
 
 /* Standard interface flags. */
 #define IFF_UP           0x1             /* interface is up               */


It resolves a circular dependency problem in the header files.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
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