www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2026/02/15/05:00:30

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 61FA0UK41295928
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 61FA0UK41295928
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=acxMocuF
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1ADEB4BAD149
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1771149629;
bh=r6VJhy99fp2+1s/R5LwMcW7cxxkw3ytQqdUkQaVmU64=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=acxMocuFcLmY1Rj3c7MB6DAtzYJtxbhLIFIHB6lp3Slmk0X8rdB0spFFgFK8G9Glg
wzl5ou8pToX2xHpljrRKyLDjbO7urIz00ltx1SOIAzPnuL835CcKazRpPPk+QLeQMK
/m2duQiBu3cdQ1UqzoeBgJi9RATY7bSKgSSgtOcI=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AEA54B9DB6F
Date: Sun, 15 Feb 2026 10:59:42 +0100
To: cygwin AT cygwin DOT com
Subject: Re: BUG: "machine/types.h" not protected by multiple #include
Message-ID: <aZGZDgPJ7CJcWpoG@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CADt9575bV4TS0AAzcfDP=W1WgqUKEoDpLHUFQjx+5twuyzPdWw AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <CADt9575bV4TS0AAzcfDP=W1WgqUKEoDpLHUFQjx+5twuyzPdWw@mail.gmail.com>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 61FA0UK41295928

On Feb 14 20:41, Carlo B. via Cygwin wrote:
> Hello,
> while compiling libsrtp2, I got this error:
> 
> /usr/include/machine/types.h:35:8: error: redefinition of ‘struct flock’
>    35 | struct flock {
>       |        ^~~~~
> In file included from /usr/include/sys/types.h:222,
>                  from
> ../gstreamer/subprojects/libsrtp-2.7.0/crypto/include/integers.h:60:
> /usr/include/machine/types.h:35:8: note: originally defined here
>    35 | struct flock {
>       |        ^~~~~
> 
> This happens because into the library there is this code:
> 
> <--- CUT --->
> #ifdef HAVE_SYS_TYPES_H
> #include <sys/types.h>
> #endif
> #ifdef HAVE_MACHINE_TYPES_H
> #include <machine/types.h>
> #endif
> <--- CUT --->
> 
> The first inclusion of "sys/types.h" includes also "machine/types.h"
> and this is ok.
> Next, the second directive includes again "machine/types.h" and here
> it generates the error.

Directly including machine/types.h is wrong.  This is a header meant
to be only included via sys/types.h.  It contains this test at the
start of the file:

#ifndef _SYS_TYPES_H
#error "must be included via <sys/types.h>"
#endif /* !_SYS_TYPES_H */

Check this against the files in /usr/include/bits from GLibc.
Many of those files are not guarded against multiple inclusions
either.

Yes, we could guard machine/types.h against multiple inclusion,
but the right thing to do would be to change the above code to
never include machine/types.h.

And if you really think you can't do without, add an #else at least:

  #ifdef HAVE_SYS_TYPES_H
  #include <sys/types.h>
  #elif defined(HAVE_MACHINE_TYPES_H)
  #include <machine/types.h>
  #endif


Corinna

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

- Raw text -


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