This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[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)
- From: Pedro Alves <palves at redhat dot com>
- To: asmwarrior <asmwarrior at gmail dot com>, GDB Patches <gdb-patches at sourceware dot org>
- Date: Mon, 16 Mar 2015 11:43:41 +0000
- Subject: [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)
- Authentication-results: sourceware.org; auth=none
- References: <1423524046-20605-1-git-send-email-palves at redhat dot com> <54F0B52F dot 1050909 at redhat dot com> <54FB20E2 dot 2040403 at redhat dot com> <54FB3C58 dot 6050702 at redhat dot com> <550660C5 dot 2060009 at gmail dot com> <5506661C dot 1040103 at gmail dot com> <55066A29 dot 8090200 at gmail dot com> <55068495 dot 5040205 at gmail dot com> <550693AB dot 60007 at gmail dot com>
On 03/16/2015 08:26 AM, asmwarrior wrote:
> int
> -tputs (char *string, int nlines, int (*outfun) ())
> +tputs (char *string, int nlines, int (*outfun) (char *))
> {
> while (*string)
> outfun (*string++);
Hmm, bitten by -fpedantic :-) :
/home/pedro/gdb/mygit/src/gdb/stub-termcap.c: In function 'int tputs(char*, int, int (*)(char*))':
/home/pedro/gdb/mygit/src/gdb/stub-termcap.c:75:22: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
outfun (*string++);
^
>From "man tputs", the correct prototype is:
int tputs(const char *str, int affcnt, int (*putc)(int));
I've pushed the patch below. Thanks!
---
>From b1a921c8c6f9e3d033629f32473c6470c360b43f Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Mon, 16 Mar 2015 11:28:23 +0000
Subject: [PATCH 2/3] stub-termcap.c: prototype tputs's parameter's parameter,
for C++ mode
src/gdb/stub-termcap.c: In function 'int tputs(char*, int, int (*)())':
src/gdb/stub-termcap.c:67:22: error: too many arguments to function
outfun (*string++);
^
gdb/ChangeLog:
2015-03-16 Pedro Alves <palves@redhat.com>
Yuanhui Zhang <asmwarrior@gmail.com>
* stub-termcap.c (tputs): Change prototype.
---
gdb/ChangeLog | 5 +++++
gdb/stub-termcap.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8828635..54cb0b2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-16 Pedro Alves <palves@redhat.com>
+ Yuanhui Zhang <asmwarrior@gmail.com>
+
+ * stub-termcap.c (tputs): Change prototype.
+
2015-03-16 Yuanhui Zhang <asmwarrior@gmail.com>
Pedro Alves <palves@redhat.com>
diff --git a/gdb/stub-termcap.c b/gdb/stub-termcap.c
index cc8632c..cecb3fb 100644
--- a/gdb/stub-termcap.c
+++ b/gdb/stub-termcap.c
@@ -29,7 +29,7 @@ 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 int tputs (char *string, int nlines, int (*outfun) (int));
extern char *tgoto (const char *cap, int col, int row);
/* Each of the files below is a minimal implementation of the standard
@@ -61,7 +61,7 @@ tgetstr (char *name, char **area)
}
int
-tputs (char *string, int nlines, int (*outfun) ())
+tputs (char *string, int nlines, int (*outfun) (int))
{
while (*string)
outfun (*string++);
--
1.9.3