[PATCH 2/3] include/dis-asm.h: Fix warning: Include "string.h" for strchr
Simon Marchi
simon.marchi@ericsson.com
Tue Jan 22 17:07:00 GMT 2019
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
More information about the Gdb-patches
mailing list