This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/3] include/dis-asm.h: Fix warning: Include "string.h" for strchr
- From: Stafford Horne <shorne at gmail dot com>
- To: GDB patches <gdb-patches at sourceware dot org>
- Cc: Stafford Horne <shorne at gmail dot com>
- Date: Sun, 2 Dec 2018 22:05:09 +0900
- Subject: [PATCH 2/3] include/dis-asm.h: Fix warning: Include "string.h" for strchr
- References: <20181202130510.10056-1-shorne@gmail.com>
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;
--
2.19.1