This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Use macro for void typecast necessary for ncurses library.



> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Joel Brobecker
> Envoyé?: Thursday, April 15, 2010 5:53 PM
> À?: Pierre Muller
> Cc?: 'Pedro Alves'; gdb-patches@sourceware.org
> Objet?: Re: [RFA] Fix compilation failure on cygwin due to ncurses
> macro.
> 
> > Thus it should become:
> >       /* We need to cast the return value of wstandout to void
> because
> >          in 2009/08/29 patch to release "5.7" of ncurses library,
> >          the wstandout macro expands to code that generates a unused-
> value
> >          warning at compilation.  */
> >
> > Is this correct?
> 
> Sounds right to me - just one nit: I think it's "an unused-value"
> rather
> than "a unused...".
> 
> Suggestion (which you are free to ignore): Would it make sense to
> define
> a new function or macro to have the cast (and therefore the comment) in
> only one place?
  Here is an implementation of your idea.

  I am unsure about:
- the name we should give to the macro.
- should the macro have a parameter?
- should I mention that it would also apply to uses of wattrset?


2010-04-16  Pierre Muller  <muller@ics.u-strasbg.fr>

	* gdb_curses.h (CURSES_CAST_TO_VOID): New macro, with
	explaination about its use.
	* tui/tui-regs.c (tui_display_register): Use new macro.
	* tui/tui-stack.c (tui_show_locator_content): Likewise.

Index: gdb_curses.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_curses.h,v
retrieving revision 1.12
diff -u -p -r1.12 gdb_curses.h
--- gdb_curses.h	1 Jan 2010 07:31:32 -0000	1.12
+++ gdb_curses.h	15 Apr 2010 22:30:53 -0000
@@ -43,4 +43,12 @@
 extern int tgetnum (const char *);
 #endif
 
+
+/* We need to cast the return value of wstandout and wstandend to void
because
+   in 2009/08/29 patch to release "5.7" of ncurses library,
+   the wstandout/wstandend macros expands to code that generates an
unused-value
+   warning at compilation.  */
+
+#define CURSES_CAST_TO_VOID (void)
+
 #endif /* gdb_curses.h */
Index: tui/tui-regs.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-regs.c,v
retrieving revision 1.37
diff -u -p -r1.37 tui-regs.c
--- tui/tui-regs.c	13 Apr 2010 12:11:09 -0000	1.37
+++ tui/tui-regs.c	15 Apr 2010 22:30:54 -0000
@@ -541,7 +541,7 @@ tui_display_register (struct tui_data_el
       int i;
 
       if (data->highlight)
-	(void) wstandout (win_info->handle);
+	CURSES_CAST_TO_VOID wstandout (win_info->handle);
       
       wmove (win_info->handle, 0, 0);
       for (i = 1; i < win_info->width; i++)
@@ -551,7 +551,7 @@ tui_display_register (struct tui_data_el
         waddstr (win_info->handle, data->content);
 
       if (data->highlight)
-	(void) wstandend (win_info->handle);
+	CURSES_CAST_TO_VOID wstandend (win_info->handle);
       tui_refresh_win (win_info);
     }
 }
Index: tui/tui-stack.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-stack.c,v
retrieving revision 1.35
diff -u -p -r1.35 tui-stack.c
--- tui/tui-stack.c	13 Apr 2010 12:11:10 -0000	1.35
+++ tui/tui-stack.c	15 Apr 2010 22:30:54 -0000
@@ -256,10 +256,10 @@ tui_show_locator_content (void)
 
       string = tui_make_status_line (&element->which_element.locator);
       wmove (locator->handle, 0, 0);
-      (void) wstandout (locator->handle);
+      CURSES_CAST_TO_VOID wstandout (locator->handle);
       waddstr (locator->handle, string);
       wclrtoeol (locator->handle);
-      (void) wstandend (locator->handle);
+      CURSES_CAST_TO_VOID wstandend (locator->handle);
       tui_refresh_win (locator);
       wmove (locator->handle, 0, 0);
       xfree (string);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]