[PATCH 2/3] include/dis-asm.h: Fix warning: Include "string.h" for strchr
Stafford Horne
shorne@gmail.com
Sun Jan 27 04:22:00 GMT 2019
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
More information about the Gdb-patches
mailing list