This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/3] include/dis-asm.h: Fix warning: Include "string.h" for strchr
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Stafford Horne <shorne at gmail dot com>, GDB patches <gdb-patches at sourceware dot org>
- Date: Tue, 22 Jan 2019 17:07:43 +0000
- Subject: Re: [PATCH 2/3] include/dis-asm.h: Fix warning: Include "string.h" for strchr
- References: <20181202130510.10056-1-shorne@gmail.com> <20181202130510.10056-3-shorne@gmail.com>
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