Message ID | 20181202130510.10056-3-shorne@gmail.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 75494 invoked by alias); 2 Dec 2018 13:05:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 75386 invoked by uid 89); 2 Dec 2018 13:05:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:mail-pf, HX-HELO:sk:mail-pf, Hx-spam-relays-external:sk:mail-pf, H*RU:sk:mail-pf X-HELO: mail-pf1-f180.google.com Received: from mail-pf1-f180.google.com (HELO mail-pf1-f180.google.com) (209.85.210.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 02 Dec 2018 13:05:23 +0000 Received: by mail-pf1-f180.google.com with SMTP id z9so5014420pfi.2 for <gdb-patches@sourceware.org>; Sun, 02 Dec 2018 05:05:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1O/HhSRI6kz2OliNTcgRq8VqZM8S+mJoO41b5vo3Y6Y=; b=XdIrOyz1OQu2q5BpucEGOcKZVE+j/nvEF76l7KcJ7KfuE9gFbLnWpShg0Me9wwT0BU 8JwmrNN9AGr1c1UUgpM6v0hfIBHtHHD580d3zfBNqLQdhU+h1wXZq8gXpYA3b9tTS4cX REwtXPDw2EJV7O6bU2esc06guj1I7ITnGRDxZaH5gB+PhRg3t423zPaJ05guv2BuMXm4 eKbKFGppc218IMJPFxh7UK49s7icVoFS5fqqEJIrgL1rFxVjpTrWDiu0mAB3FC7U8TB2 76QsKMIVeCnf+QvdSs0hUN/VtukwPzdtpfFq9Qt8SHeUeby2CBofYJqyGrhNO996vE2s fj4w== Return-Path: <shorne@gmail.com> Received: from localhost (g206.124-44-15.ppp.wakwak.ne.jp. [124.44.15.206]) by smtp.gmail.com with ESMTPSA id 186sm16250503pga.36.2018.12.02.05.05.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Dec 2018 05:05:21 -0800 (PST) From: Stafford Horne <shorne@gmail.com> To: GDB patches <gdb-patches@sourceware.org> Cc: Stafford Horne <shorne@gmail.com> Subject: [PATCH 2/3] include/dis-asm.h: Fix warning: Include "string.h" for strchr Date: Sun, 2 Dec 2018 22:05:09 +0900 Message-Id: <20181202130510.10056-3-shorne@gmail.com> In-Reply-To: <20181202130510.10056-1-shorne@gmail.com> References: <20181202130510.10056-1-shorne@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes |
Commit Message
Stafford Horne
Dec. 2, 2018, 1:05 p.m. UTC
I got this warning when building the OpenRISC sim target. Warning: In file included from ../../../binutils-gdb/sim/or1k/../common/cgen-trace.c:26: ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h: In function ‘next_disassembler_option’: ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: warning: implicit declaration of function ‘strchr’ [-Wimplicit-function-declaration] const char *opt = strchr (options, ','); ^~~~~~ ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: warning: incompatible implicit declaration of built-in function ‘strchr’ ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: note: include ‘<string.h>’ or provide a declaration of ‘strchr’ ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:40:1: +#include <string.h> ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: const char *opt = strchr (options, ','); ^~~~~~ include/ChangeLog: dis-asm.h: Include "string.h" --- include/dis-asm.h | 4 ++++ 1 file changed, 4 insertions(+)
Comments
On 2018-12-02 8:05 a.m., Stafford Horne wrote: > I got this warning when building the OpenRISC sim target. > > Warning: > > In file included from ../../../binutils-gdb/sim/or1k/../common/cgen-trace.c:26: > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h: In function ‘next_disassembler_option’: > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: warning: implicit declaration of function ‘strchr’ [-Wimplicit-function-declaration] > const char *opt = strchr (options, ','); > ^~~~~~ > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: warning: incompatible implicit declaration of built-in function ‘strchr’ > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: note: include ‘<string.h>’ or provide a declaration of ‘strchr’ > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:40:1: > +#include <string.h> > > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: > const char *opt = strchr (options, ','); > ^~~~~~ > > include/ChangeLog: > > dis-asm.h: Include "string.h" > --- > include/dis-asm.h | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/include/dis-asm.h b/include/dis-asm.h > index 84627950c0..823bba5b45 100644 > --- a/include/dis-asm.h > +++ b/include/dis-asm.h > @@ -32,6 +32,10 @@ extern "C" { > #endif > > #include <stdio.h> > +/* For strchr. */ > +#ifdef HAVE_STRING_H > +#include <string.h> > +#endif > #include "bfd.h" > > typedef int (*fprintf_ftype) (void *, const char*, ...) ATTRIBUTE_FPTR_PRINTF_2; > Hi Stafford, It looks like this patchset fell through the cracks (I found it while searching for something else). A version of this patch went in, witout the HAVE_STRING_H ifdef. Do you think the ifdef is necessary in practice? Simon
On Tue, Jan 22, 2019 at 05:07:43PM +0000, Simon Marchi wrote: > On 2018-12-02 8:05 a.m., Stafford Horne wrote: > > I got this warning when building the OpenRISC sim target. > > > > Warning: > > > > In file included from ../../../binutils-gdb/sim/or1k/../common/cgen-trace.c:26: > > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h: In function ‘next_disassembler_option’: > > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: warning: implicit declaration of function ‘strchr’ [-Wimplicit-function-declaration] > > const char *opt = strchr (options, ','); > > ^~~~~~ > > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: warning: incompatible implicit declaration of built-in function ‘strchr’ > > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: note: include ‘<string.h>’ or provide a declaration of ‘strchr’ > > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:40:1: > > +#include <string.h> > > > > ../../../binutils-gdb/sim/or1k/../../include/dis-asm.h:343:21: > > const char *opt = strchr (options, ','); > > ^~~~~~ > > > > include/ChangeLog: > > > > dis-asm.h: Include "string.h" > > --- > > include/dis-asm.h | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/include/dis-asm.h b/include/dis-asm.h > > index 84627950c0..823bba5b45 100644 > > --- a/include/dis-asm.h > > +++ b/include/dis-asm.h > > @@ -32,6 +32,10 @@ extern "C" { > > #endif > > > > #include <stdio.h> > > +/* For strchr. */ > > +#ifdef HAVE_STRING_H > > +#include <string.h> > > +#endif > > #include "bfd.h" > > > > typedef int (*fprintf_ftype) (void *, const char*, ...) ATTRIBUTE_FPTR_PRINTF_2; > > > > Hi Stafford, > > It looks like this patchset fell through the cracks (I found it while searching for > something else). A version of this patch went in, witout the HAVE_STRING_H ifdef. > Do you think the ifdef is necessary in practice? Sorry for the late reply, I just got back from vacation with the family in Hawaii :). I thought about this when I made this patch, we currently have a lot of these HAVE_XXX_H checks throughout the sim code. I am not sure of the history, but perhaps I can try a patch set to eliminate a few of them like HAVE_STRING_H vs HAVE_STRINGS_H (BSD). I would think everything we need is in on every machine in <string.h>. I am not an expert in C/C++ compatibility. Is there at minimum standard c/c++ required for gdb? Perhaps this has changed since we moved to allow C++. -Stafford
>>>>> "Stafford" == Stafford Horne <shorne@gmail.com> writes:
I didn't see a reply to this, apologies if I missed it somehow.
Stafford> I thought about this when I made this patch, we currently have a lot of these
Stafford> HAVE_XXX_H checks throughout the sim code. I am not sure of the history, but
Stafford> perhaps I can try a patch set to eliminate a few of them like HAVE_STRING_H vs
Stafford> HAVE_STRINGS_H (BSD). I would think everything we need is in on every machine
Stafford> in <string.h>.
The old BSD one is surely long obsolete.
The sim could also consider using gnulib. This isn't totally trivial --
we'd probably have to move it to the top level, though I've wanted us to
do that for a while now -- but it would mean not having to care so much
about checking for standard headers.
Stafford> I am not an expert in C/C++ compatibility. Is there at minimum standard c/c++
Stafford> required for gdb? Perhaps this has changed since we moved to allow C++.
gdb uses C++11. The rest of the tree uses C89 as far as I know.
Tom
diff --git a/include/dis-asm.h b/include/dis-asm.h index 84627950c0..823bba5b45 100644 --- a/include/dis-asm.h +++ b/include/dis-asm.h @@ -32,6 +32,10 @@ extern "C" { #endif #include <stdio.h> +/* For strchr. */ +#ifdef HAVE_STRING_H +#include <string.h> +#endif #include "bfd.h" typedef int (*fprintf_ftype) (void *, const char*, ...) ATTRIBUTE_FPTR_PRINTF_2;