[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1057573: linpac: FTBFS: error: invalid use of incomplete type ‘WINDOW’ {aka ‘struct _win_st’}



Control: tags -1 + patch

On 2023-12-05 23:07 +0100, Santiago Vila wrote:

> Package: src:linpac
> Version: 0.28-2
> Severity: serious
> Tags: ftbfs
>
> Dear maintainer:
>
> During a rebuild of all packages in unstable, your package failed to build:
>
> --------------------------------------------------------------------------------
> [...]
> g++ -DHAVE_CONFIG_H -I. -I../../..   -Wdate-time -D_FORTIFY_SOURCE=2  -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -c -o mail_screen.o mail_screen.cc
> mail_screen.cc: In function ‘void init_main_screen()’:
> mail_screen.cc:39:16: error: invalid use of incomplete type ‘WINDOW’ {aka ‘struct _win_st’}
>    39 |   maxx = stdscr->_maxx;
>       |                ^~
> In file included from mail_screen.cc:13:
> /usr/include/curses.h:442:16: note: forward declaration of ‘WINDOW’ {aka ‘struct _win_st’}
>   442 | typedef struct _win_st WINDOW;
>       |                ^~~~~~~
> mail_screen.cc:40:16: error: invalid use of incomplete type ‘WINDOW’ {aka ‘struct _win_st’}
>    40 |   maxy = stdscr->_maxy;
>       |                ^~
> /usr/include/curses.h:442:16: note: forward declaration of ‘WINDOW’ {aka ‘struct _win_st’}
>   442 | typedef struct _win_st WINDOW;
>       |                ^~~~~~~
> mail_screen.cc: In function ‘void redraw()’:
> mail_screen.cc:70:15: error: invalid use of incomplete type ‘WINDOW’ {aka ‘struct _win_st’}
>    70 |    main_window->_clear = TRUE;
>       |               ^~
> /usr/include/curses.h:442:16: note: forward declaration of ‘WINDOW’ {aka ‘struct _win_st’}
>   442 | typedef struct _win_st WINDOW;

The attached patch, which can be added to the series file fixes, these
errors and two additional ones in src/linpac.cc, but I have only tested
that the package builds, not if it works.  Note that getmaxx(win)
returns win->_maxx + 1, and similar for getmaxy.

Cheers,
       Sven

From 205aeb6a6c956589ad2a94d16778a138057dfc6e Mon Sep 17 00:00:00 2001
From: Sven Joachim <svenjoac@gmx.de>
Date: Sat, 16 Dec 2023 18:45:57 +0100
Subject: [PATCH] Avoid accessing internal ncurses structures

Since ncurses patchlevel 20231021 the WINDOW structure is opaque, its
members cannot be addressed directly.  Use the functions ncurses
provides for this purpose instead.
---
 src/applications/mailer/mail_screen.cc | 6 +++---
 src/linpac.cc                          | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/applications/mailer/mail_screen.cc b/src/applications/mailer/mail_screen.cc
index 688b8ca..54697e4 100644
--- a/src/applications/mailer/mail_screen.cc
+++ b/src/applications/mailer/mail_screen.cc
@@ -36,8 +36,8 @@ void init_main_screen()
 {
   initscr();

-  maxx = stdscr->_maxx;
-  maxy = stdscr->_maxy;
+  maxx = getmaxx(stdscr) -1;
+  maxy = getmaxy(stdscr) -1;
   noecho();
   cbreak();
   nodelay(stdscr, TRUE);
@@ -67,7 +67,7 @@ void init_main_screen()

 void redraw()
 {
-   main_window->_clear = TRUE;
+   clearok(main_window, TRUE);
    redrawwin(main_window);
    wrefresh(main_window);
    /*if (focus_window != NULL)
diff --git a/src/linpac.cc b/src/linpac.cc
index 54cfa09..1796f88 100644
--- a/src/linpac.cc
+++ b/src/linpac.cc
@@ -234,8 +234,8 @@ void init()
     setIConfig("edit_end_line", 17);
     setIConfig("chn_line", iconfig("edit_end_line") + 1);
     setIConfig("mon_start_line", iconfig("chn_line") +1);
-    setIConfig("mon_end_line", stdscr->_maxy);
-    setIConfig("max_x", stdscr->_maxx);
+    setIConfig("mon_end_line", getmaxy(stdscr) -1);
+    setIConfig("max_x", getmaxx(stdscr) -1);
     setBConfig("swap_edit", false);
     setBConfig("monitor", true);
     setBConfig("mon_bin", true);
--
2.43.0


Reply to: