From patchwork Mon Mar 16 11:46:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 5628 Received: (qmail 67887 invoked by alias); 16 Mar 2015 11:46:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 67877 invoked by uid 89); 16 Mar 2015 11:46:42 -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; Mon, 16 Mar 2015 11:46:42 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id DB6862B51B9; Mon, 16 Mar 2015 11:46:40 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2GBkdrp022939; Mon, 16 Mar 2015 07:46:39 -0400 Message-ID: <5506C29F.1000703@redhat.com> Date: Mon, 16 Mar 2015 11:46:39 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: asmwarrior , GDB Patches Subject: [pushed] stub termcap, add extern "C" (Re: [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program) References: <1423524046-20605-1-git-send-email-palves@redhat.com> <54F0B52F.1050909@redhat.com> <54FB20E2.2040403@redhat.com> <54FB3C58.6050702@redhat.com> <550660C5.2060009@gmail.com> <5506661C.1040103@gmail.com> <55066A29.8090200@gmail.com> <55068495.5040205@gmail.com> <550693AB.60007@gmail.com> In-Reply-To: <550693AB.60007@gmail.com> On 03/16/2015 08:26 AM, asmwarrior wrote: > diff --git a/gdb/gdb_curses.h b/gdb/gdb_curses.h > index 9b3707a..d02cab3 100644 > --- a/gdb/gdb_curses.h > +++ b/gdb/gdb_curses.h > @@ -51,7 +51,7 @@ > of the termcap functions will be built from stub-termcap.c. Readline > provides its own extern declarations when there's no termcap.h; do the > same here for the termcap functions used in GDB. */ > -extern int tgetnum (const char *); > +extern "C" int tgetnum (const char *); This still needs to be plain "extern" in C mode. We can use EXTERN_C for this. > #endif > > /* SunOS's curses.h has a '#define reg register' in it. Thank you Sun. */ > diff --git a/gdb/stub-termcap.c b/gdb/stub-termcap.c > index cc8632c..a2e833a 100644 > --- a/gdb/stub-termcap.c > +++ b/gdb/stub-termcap.c > @@ -23,14 +23,20 @@ > #include "defs.h" > > #include > - > +#ifdef __cplusplus > +extern "C" { > +#endif > /* -Wmissing-prototypes */ > -extern int tgetent (char *buffer, char *termtype); > -extern int tgetnum (char *name); > -extern int tgetflag (char *name); > -extern char* tgetstr (char *name, char **area); > -extern int tputs (char *string, int nlines, int (*outfun) ()); > -extern char *tgoto (const char *cap, int col, int row); > +int tgetent (char *buffer, char *termtype); > +int tgetnum (char *name); > +int tgetflag (char *name); > +char* tgetstr (char *name, char **area); > +int tputs (char *string, int nlines, int (*outfun) (char *)); > +char *tgoto (const char *cap, int col, int row); > +#ifdef __cplusplus > +} > +#endif > + We can keep the externs. Here's what I pushed. Thanks! --- From d053f6be557fa3bedd4ccbd969103dbb51a37439 Mon Sep 17 00:00:00 2001 From: Yuanhui Zhang Date: Mon, 16 Mar 2015 11:28:24 +0000 Subject: [PATCH 3/3] stub termcap, add extern "C" Fixes linking an --enable-build-with-cxx build on mingw: ../readline/terminal.c:278: undefined reference to `tgetnum' ../readline/terminal.c:297: undefined reference to `tgetnum' ../readline/libreadline.a(terminal.o): In function `get_term_capabilities': ../readline/terminal.c:427: undefined reference to `tgetstr' ../readline/libreadline.a(terminal.o): In function `_rl_init_terminal_io': [etc.] gdb/ChangeLog: 2015-03-16 Yuanhui Zhang Pedro Alves * gdb_curses.h (tgetnum): Mark with EXTERN_C. * stub-termcap.c (tgetent, tgetnum, tgetflag, tgetstr, tputs) (tgoto): Wrap with extern "C". --- gdb/ChangeLog | 7 +++++++ gdb/gdb_curses.h | 2 +- gdb/stub-termcap.c | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 54cb0b2..eb8ef87 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2015-03-16 Yuanhui Zhang + Pedro Alves + + * gdb_curses.h (tgetnum): Mark with EXTERN_C. + * stub-termcap.c (tgetent, tgetnum, tgetflag, tgetstr, tputs) + (tgoto): Wrap with extern "C". + 2015-03-16 Pedro Alves Yuanhui Zhang diff --git a/gdb/gdb_curses.h b/gdb/gdb_curses.h index 9b3707a..a89383f 100644 --- a/gdb/gdb_curses.h +++ b/gdb/gdb_curses.h @@ -51,7 +51,7 @@ of the termcap functions will be built from stub-termcap.c. Readline provides its own extern declarations when there's no termcap.h; do the same here for the termcap functions used in GDB. */ -extern int tgetnum (const char *); +EXTERN_C int tgetnum (const char *); #endif /* SunOS's curses.h has a '#define reg register' in it. Thank you Sun. */ diff --git a/gdb/stub-termcap.c b/gdb/stub-termcap.c index cecb3fb..5897d89 100644 --- a/gdb/stub-termcap.c +++ b/gdb/stub-termcap.c @@ -24,6 +24,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /* -Wmissing-prototypes */ extern int tgetent (char *buffer, char *termtype); extern int tgetnum (char *name); @@ -32,6 +36,10 @@ extern char* tgetstr (char *name, char **area); extern int tputs (char *string, int nlines, int (*outfun) (int)); extern char *tgoto (const char *cap, int col, int row); +#ifdef __cplusplus +} +#endif + /* Each of the files below is a minimal implementation of the standard termcap function with the same name, suitable for use in a Windows console window. */