From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3250 invoked by alias); 11 Feb 2015 11:51:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 3237 invoked by uid 89); 11 Feb 2015 11:51:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 11 Feb 2015 11:51:29 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1BBpR65024218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 11 Feb 2015 06:51:27 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1BBpQ7R023769 for ; Wed, 11 Feb 2015 06:51:27 -0500 Message-ID: <54DB423E.7040206@redhat.com> Date: Wed, 11 Feb 2015 11:51:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Re: [PATCH 10/36] Add extern "C" to declarations of C symbols References: <1423524046-20605-1-git-send-email-palves@redhat.com> <1423524046-20605-11-git-send-email-palves@redhat.com> In-Reply-To: <1423524046-20605-11-git-send-email-palves@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-02/txt/msg00304.txt.bz2 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 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 * 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 #include -- 1.9.3