From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36733 invoked by alias); 19 May 2017 16:07:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 36695 invoked by uid 89); 19 May 2017 16:07:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,URIBL_RED autolearn=no version=3.3.2 spammy= X-HELO: mail-wr0-f178.google.com Received: from mail-wr0-f178.google.com (HELO mail-wr0-f178.google.com) (209.85.128.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 May 2017 16:07:06 +0000 Received: by mail-wr0-f178.google.com with SMTP id z52so19862005wrc.2 for ; Fri, 19 May 2017 09:07:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=HeP+LXr3wUFmgqoCcZxHJTakESriddPF1VN30tQEYfs=; b=pVLxkFuvkYvMqYyJV0WXXSkxODq6PSOd7+s6Ku1Kffvj940j47s7U04FYlTQoxzK0F kPgAdvLnaKXBqnXKqtxo8gyaBoJvTQIxkg3ZMWbWci9baJ6Os7sx+IB+4H4P7DfC55Ml T/VU5GknTNCAQq/8zYp0x7U80udtaTsyigDduilkiwMZa8NgQz8FJ7z0uZscc3hYhMv1 Hxj0noD95DZe6h5rQah2hkWx+pVPfIb/eKnxeP7bhNXgM7XORGAmC0tfFAB1EhwnrVrk T4yrdukHVjZoeR/W48nffAIcY+OT0j8WbhPtVlQ8uF9ooAmEWV031qYqFt7Cccj1MxdM 8E2w== X-Gm-Message-State: AODbwcD1tGg5erjUrE3ArxNs7OOjTpI/rH2na1cO2s/yLcULL/q89x+J HVZ5kOyHvhSmvkHHLpWe7Q== X-Received: by 10.223.170.195 with SMTP id i3mr4313420wrc.49.1495210027753; Fri, 19 May 2017 09:07:07 -0700 (PDT) Received: from [192.168.0.102] ([37.189.166.198]) by smtp.gmail.com with ESMTPSA id p107sm2849599wrb.64.2017.05.19.09.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 09:07:06 -0700 (PDT) Subject: Re: MinGW compilation warnings in libiberty's xstrndup.c To: Eli Zaretskii References: <83h90vcqo6.fsf@gnu.org> <60a354b0-6c1a-15ea-177a-8bdb198c8c03@redhat.com> <83a8683ler.fsf@gnu.org> Cc: gcc-patches@gcc.gnu.org, gdb-patches@sourceware.org, thomas@codesourcery.com From: Pedro Alves Message-ID: Date: Fri, 19 May 2017 16:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <83a8683ler.fsf@gnu.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-05/txt/msg00457.txt.bz2 On 05/19/2017 04:40 PM, Eli Zaretskii wrote: >> Cc: gdb-patches@sourceware.org, Thomas Schwinge >> From: Pedro Alves >> Date: Fri, 19 May 2017 16:22:55 +0100 >> >> But then, xstrndup.c has at the top: >> >> #ifdef HAVE_STRING_H >> #include >> #else >> # ifdef HAVE_STRINGS_H >> # include >> # endif >> #endif >> >> So I would expect your build to pick the strnlen declaration from >> one of the string.h or strings.h mingw headers. Why didn't it? > > Because MinGW doesn't have it, not unless you build a program that > will require one of the newer versions of the Windows C runtime > library. That's why libiberty's strnlen is being compiled in the > MinGW build in the first place. OK, I didn't realize there was a strnlen replacement too. > > Specifically, the MinGW headers do provide a prototype for strnlen if > the program defines __MSVCRT_VERSION__ to be a high enough version, or > defines _POSIX_C_SOURCE >= 200809L, but none of these is set by > default, and is not a good idea, as explained above, for a program > that needs to run on a wide variety of OS versions. > > IOW, libiberty shouldn't rely on the system headers to provide a > strnlen prototype when libiberty's strnlen is being included in the > library as a replacement. OK, I guess then we're up to figuring out which direction to go. Either an AC_CHECK_DECL is missing on libiberty's configure, or the original patch really wanted AC_CHECK_FUNC instead of AC_CHECK_DECL. Or something else, I only look at libiberty's configury every couple of years and forget how this is all supposed to work in between. Thanks, Pedro Alves