From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 10/36] Add extern "C" to declarations of C symbols
Date: Wed, 11 Feb 2015 11:51:00 -0000 [thread overview]
Message-ID: <54DB423E.7040206@redhat.com> (raw)
In-Reply-To: <1423524046-20605-11-git-send-email-palves@redhat.com>
On 02/09/2015 11:20 PM, Pedro Alves wrote:
> As for the linux-tdep.c change: elf-bfd.h wraps itself in extern "C"
> already, while elf/common.h does not. Since elf/common.h is already
> included by "elf-bfd.h", simply remove the explicit elf/common.h
> include.
Dunno what I was thinking here. :-) This wasn't necessary, not
even before revised BFD extern "C" patch that went in.
Here's the updated patch without that bit.
(I've been rebasing the series and force-pushing to my github branch,
as patches are updated or pushed to master:
git@github.com:palves/gdb.git palves/cxx-conversion-attempt)
--------
From 76168c4f096717c5921fed547f561fd7e336fa36 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Mon, 9 Feb 2015 14:59:08 +0000
Subject: [PATCH] Add extern "C" to declarations of C symbols
These symbols are defined in C code, so in C++ mode we need to use
extern "C" to declare them. As extern "C" can't be used inside a
function's scope, we move the declarations to the global scope at the
same time.
gdb/ChangeLog:
2015-02-11 Pedro Alves <palves@redhat.com>
* cli-out.c (_rl_erase_entire_line): Move declaration out of
cli_mld_erase_entire_line, and make it extern "C".
* common/common-defs.h (EXTERN_C): New.
* completer.c (_rl_completion_prefix_display_length)
(_rl_print_completions_horizontally, QSFUNC): Move declarations
out of gdb_display_match_list_1.
(_rl_qsort_string_compare): Move declaration out of
gdb_display_match_list_1, and make it extern "C".
* defs.h (re_comp): Use EXTERN_C.
* maint.c (_mcleanup): Move declaration out of mcleanup_wrapper,
and make it extern "C".
(monstartup): Move declaration out of maintenance_set_profile_cmd,
and make it extern "C".
(main): Move declaration out of maintenance_set_profile_cmd.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason_string): Use
EXTERN_C.
---
gdb/cli-out.c | 4 ++--
gdb/common/common-defs.h | 6 ++++++
gdb/completer.c | 10 ++++++----
gdb/defs.h | 2 +-
gdb/maint.c | 10 +++++-----
gdb/nat/linux-ptrace.c | 2 +-
6 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 48f2a04..2a83169 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -452,13 +452,13 @@ cli_mld_flush (const struct match_list_displayer *displayer)
fflush (rl_outstream);
}
+EXTERN_C void _rl_erase_entire_line (void);
+
/* CLI version of displayer.erase_entire_line. */
static void
cli_mld_erase_entire_line (const struct match_list_displayer *displayer)
{
- extern void _rl_erase_entire_line (void);
-
_rl_erase_entire_line ();
}
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index e80d332..3020bd8 100644
--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -50,4 +50,10 @@
#include "cleanups.h"
#include "common-exceptions.h"
+#ifdef __cplusplus
+# define EXTERN_C extern "C"
+#else
+# define EXTERN_C extern
+#endif
+
#endif /* COMMON_DEFS_H */
diff --git a/gdb/completer.c b/gdb/completer.c
index bfd2788..774fb31 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1555,6 +1555,12 @@ gdb_complete_get_screenwidth (const struct match_list_displayer *displayer)
return displayer->width;
}
+extern int _rl_completion_prefix_display_length;
+extern int _rl_print_completions_horizontally;
+
+EXTERN_C int _rl_qsort_string_compare (const void *, const void *);
+typedef int QSFUNC (const void *, const void *);
+
/* GDB version of readline/complete.c:rl_display_match_list.
See gdb_display_match_list for a description of MATCHES, LEN, MAX.
Returns non-zero if all matches are displayed. */
@@ -1567,10 +1573,6 @@ gdb_display_match_list_1 (char **matches, int len, int max,
int i, j, k, l, common_length, sind;
char *temp, *t;
int page_completions = displayer->height != INT_MAX && pagination_enabled;
- extern int _rl_completion_prefix_display_length;
- extern int _rl_qsort_string_compare (const void *, const void *);
- extern int _rl_print_completions_horizontally;
- typedef int QSFUNC (const void *, const void *);
/* Find the length of the prefix common to all items: length as displayed
characters (common_length) and as a byte index into the matches (sind) */
diff --git a/gdb/defs.h b/gdb/defs.h
index a1cd45f..72512f6 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -249,7 +249,7 @@ extern int annotation_level; /* in stack.c */
"const char *" in unistd.h, so we can't declare the argument
as "char *". */
-extern char *re_comp (const char *);
+EXTERN_C char *re_comp (const char *);
/* From symfile.c */
diff --git a/gdb/maint.c b/gdb/maint.c
index be18a32..1adea2f 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -683,15 +683,18 @@ extern char etext;
static int profiling_state;
+EXTERN_C void _mcleanup (void);
+
static void
mcleanup_wrapper (void)
{
- extern void _mcleanup (void);
-
if (profiling_state)
_mcleanup ();
}
+EXTERN_C void monstartup (unsigned long, unsigned long);
+extern int main ();
+
static void
maintenance_set_profile_cmd (char *args, int from_tty,
struct cmd_list_element *c)
@@ -705,9 +708,6 @@ maintenance_set_profile_cmd (char *args, int from_tty,
{
static int profiling_initialized;
- extern void monstartup (unsigned long, unsigned long);
- extern int main();
-
if (!profiling_initialized)
{
atexit (mcleanup_wrapper);
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 0ce258f..e36864c 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -84,7 +84,7 @@ linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err)
#if defined __i386__ || defined __x86_64__
/* Address of the 'ret' instruction in asm code block below. */
-extern void (linux_ptrace_test_ret_to_nx_instr) (void);
+EXTERN_C void linux_ptrace_test_ret_to_nx_instr (void);
#include <sys/reg.h>
#include <sys/mman.h>
--
1.9.3
next prev parent reply other threads:[~2015-02-11 11:51 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-09 23:20 [PATCH 00/36] Support building GDB as a C++ program Pedro Alves
2015-02-09 23:20 ` [PATCH 02/36] Add --enable-build-with-cxx configure switch Pedro Alves
2015-02-10 22:11 ` Yao Qi
2015-02-27 13:24 ` Pedro Alves
2015-02-27 14:20 ` Yao Qi
2015-02-27 16:29 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 25/36] python/python-internal.h: enum ‘ext_lang_rc’ not defined Pedro Alves
2015-02-09 23:21 ` [PATCH 28/36] Move exception_none to common code, and use it Pedro Alves
2015-02-09 23:21 ` [PATCH 17/36] mi/mi-cmd-stack.c|frame filters: print_values <-> ext_lang_frame_args Pedro Alves
2015-02-09 23:21 ` [PATCH 03/36] C++ keyword cleanliness, mostly auto-generated Pedro Alves
2015-02-11 7:57 ` Joel Brobecker
2015-02-11 8:52 ` Phil Muldoon
2015-02-11 10:27 ` Pedro Alves
2015-02-11 10:51 ` Pedro Alves
2015-02-12 12:19 ` Joel Brobecker
2015-02-12 13:14 ` Pedro Alves
2015-02-12 14:43 ` Pedro Alves
2015-02-12 14:59 ` Joel Brobecker
2015-02-27 17:41 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 19/36] Exported const objects Pedro Alves
2015-02-09 23:21 ` [PATCH 16/36] x86 Linux/ptrace: fix offsetof usage in C++ mode Pedro Alves
2015-02-09 23:21 ` [PATCH 04/36] Fix struct, union, and enum nesting in C++ Pedro Alves
2015-02-09 23:21 ` [PATCH 26/36] Adjust self tests to cope with GDB built as a C++ program Pedro Alves
2015-02-09 23:21 ` [PATCH 29/36] Normalize TRY_CATCH exception handling block Pedro Alves
2015-02-09 23:21 ` [PATCH 27/36] catch_command_errors: Remove 'mask' parameter Pedro Alves
2015-02-09 23:21 ` [PATCH 11/36] Make functions and variables exported by the IPA be extern "C" Pedro Alves
2015-02-09 23:21 ` [PATCH 12/36] proc-service, " Pedro Alves
2015-02-09 23:21 ` [PATCH 31/36] Split TRY_CATCH into TRY + CATCH Pedro Alves
2015-03-07 15:58 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 23/36] gdbarch.h: include regcache.h Pedro Alves
2015-02-09 23:21 ` [PATCH 15/36] Don't forward declare enum target_hw_bp_type Pedro Alves
2015-02-09 23:21 ` [PATCH 22/36] Remove duplicate const Pedro Alves
2015-02-09 23:21 ` [PATCH 13/36] target.h: Include infrun.h Pedro Alves
2015-02-09 23:21 ` [PATCH 21/36] opcodes/microblaze: Rename 'or', 'and', 'xor' to avoid C++ conflict Pedro Alves
2015-02-10 15:05 ` Michael Eager
2015-02-10 18:11 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 09/36] floatformat.h: Wrap in extern "C" Pedro Alves
2015-02-09 23:35 ` Andrew Pinski
2015-02-09 23:49 ` Pedro Alves
2015-02-12 11:49 ` Pedro Alves
2015-02-18 19:55 ` Jakub Jelinek
2015-02-14 17:29 ` Doug Evans
2015-02-14 18:36 ` Pedro Alves
2015-02-14 22:46 ` Doug Evans
2015-02-09 23:21 ` [PATCH 20/36] gdbserver/tracepoint: Add cast sockaddr_un/sockaddr cast Pedro Alves
2015-02-09 23:21 ` [PATCH 08/36] elf-bfd.h: Wrap in extern "C" Pedro Alves
2015-02-09 23:33 ` Andrew Pinski
2015-02-10 12:05 ` [PATCH v2] Wrap BFD headers " Pedro Alves
2015-02-11 0:36 ` Alan Modra
2015-02-11 10:08 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 05/36] Fix redefinition errors in C++ mode Pedro Alves
2015-02-11 10:09 ` Yao Qi
2015-02-11 11:30 ` Pedro Alves
2015-02-11 11:39 ` [PATCH] xcoffread.c: delete 'within_function' definition (Re: [PATCH 05/36] Fix redefinition errors in C++ mode) Pedro Alves
2015-02-09 23:22 ` [PATCH 36/36] Make TRY/CATCH use real C++ try/catch in C++ mode Pedro Alves
2015-02-09 23:22 ` [PATCH 32/36] TRY_CATCH -> TRY+CATCH+END_CATCH everywhere Pedro Alves
2015-02-09 23:22 ` [PATCH 33/36] TRY_CATCH -> TRY+CATCH+END_CATCH, the manual conversions Pedro Alves
2015-02-09 23:35 ` [PATCH 18/36] Rename struct lzma_stream to avoid clash with system header Pedro Alves
2015-02-09 23:45 ` [PATCH 06/36] record-btrace.c: Remove redefinitions Pedro Alves
2015-02-09 23:46 ` [PATCH 35/36] kill volatile struct gdb_exception Pedro Alves
2015-02-09 23:49 ` [PATCH 00/36] Support building GDB as a C++ program Doug Evans
2015-02-09 23:50 ` [PATCH 34/36] more making TRY/CATCH callers look more like real C++ try/catch blocks Pedro Alves
2015-03-07 15:59 ` Pedro Alves
2015-02-09 23:51 ` [PATCH 07/36] Make array object extern Pedro Alves
2015-02-27 22:47 ` Simon Marchi
2015-02-27 22:58 ` Pedro Alves
2015-02-27 23:04 ` Simon Marchi
2015-02-09 23:51 ` [PATCH 14/36] Do not do arithmetic on enum types Pedro Alves
2015-02-09 23:53 ` [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it Pedro Alves
2015-02-09 23:35 ` Pedro Alves
2015-02-27 16:23 ` Pedro Alves
2015-02-09 23:54 ` [PATCH 30/36] quit_force: Replace TRY_CATCH wrapper macros Pedro Alves
2015-02-09 23:54 ` [PATCH 10/36] Add extern "C" to declarations of C symbols Pedro Alves
2015-02-11 11:51 ` Pedro Alves [this message]
2015-02-10 0:21 ` [PATCH 24/36] breakpoint.h: move enum ‘print_stop_action’ Pedro Alves
2015-02-11 12:28 ` Yao Qi
2015-02-10 15:07 ` [PATCH 00/36] Support building GDB as a C++ program Michael Eager
2015-02-11 17:15 ` Yao Qi
2015-02-12 11:34 ` Pedro Alves
2015-02-17 23:19 ` Patrick Palka
2015-02-18 21:54 ` Yao Qi
2015-02-18 23:49 ` Patrick Palka
2015-02-27 18:19 ` Pedro Alves
2015-02-27 23:52 ` Patrick Palka
2015-02-28 0:09 ` Pedro Alves
2015-03-07 16:01 ` Pedro Alves
2015-03-07 17:58 ` [all pushed] " Pedro Alves
2015-03-16 4:42 ` asmwarrior
2015-03-16 5:05 ` asmwarrior
2015-03-16 5:22 ` asmwarrior
2015-03-16 7:15 ` asmwarrior
2015-03-16 8:20 ` asmwarrior
2015-03-16 11:43 ` [pushed] stub-termcap.c: prototype tputs's parameter's parameter, for C++ mode (Re: [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program) Pedro Alves
2015-03-16 11:46 ` [pushed] stub termcap, add extern "C" " Pedro Alves
2015-03-16 11:55 ` [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program Pedro Alves
2015-03-16 11:42 ` Pedro Alves
2015-05-15 8:13 ` asmwarrior
2015-05-15 8:24 ` asmwarrior
2015-05-15 15:09 ` Pedro Alves
2015-05-15 15:04 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54DB423E.7040206@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox