Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

petitboot doesn't build against ncurses with NCURSES_OPAQUE_MENU #106

Open
ollieparanoid opened this issue Dec 3, 2023 · 0 comments
Open

Comments

@ollieparanoid
Copy link

Building current version 1.14 (2c04d96) of petitboot in postmarketOS v23.12 / Alpine Linux 3.19, with ncurses 6.4_p20231125 and gcc 13.2.1_git20231014 fails with:

In file included from ui/ncurses/nc-cui.h:25,
                 from ui/ncurses/generic-main.c:41:
ui/ncurses/nc-menu.h: In function 'pmenu_dump_item':
ui/ncurses/nc-menu.h:129:47: error: invalid use of incomplete typedef 'ITEM' {aka 'const struct tagITEM'}
  129 |         pb_debug("%p %s\n", item, (item ? item->name.str : "(null)"));
      |                                               ^~
ui/ncurses/nc-menu.h: In function 'pmenu_dump_items':
ui/ncurses/nc-menu.h:138:45: error: invalid use of incomplete typedef 'ITEM' {aka 'struct tagITEM'}
  138 |                         (items[i] ? items[i]->name.str : "(null)"));
      |                                             ^~
make[2]: *** [Makefile:5726: ui/ncurses/petitboot_nc-generic-main.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/pmos/build/src/petitboot-v1.13'
make[1]: *** [Makefile:5907: all-recursive] Error 1
make[1]: Leaving directory '/home/pmos/build/src/petitboot-v1.13'
make: *** [Makefile:2824: all] Error 2

Looking at ncurses menu.h:

  typedef struct tagITEM
#if !NCURSES_OPAQUE_MENU
    {
      TEXT name;                /* name of menu item                         */
      TEXT description;         /* description of item, optional in display  */
      struct tagMENU *imenu;    /* Pointer to parent menu                    */
      void *userptr;            /* Pointer to user defined per item data     */
      Item_Options opt;         /* Item options                              */
      short index;              /* Item number if connected to a menu        */
      short y;                  /* y and x location of item in menu          */
      short x;
      bool value;               /* Selection value                           */

      struct tagITEM *left;     /* neighbor items                            */
      struct tagITEM *right;
      struct tagITEM *up;
      struct tagITEM *down;

    }
#endif                          /* !NCURSES_OPAQUE_MENU */ 
  ITEM;  

So item_name() has to be used instead of item->name.str. Here is half a patch:

diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h
index eb568c8..550c7e1 100644
--- a/ui/ncurses/nc-menu.h
+++ b/ui/ncurses/nc-menu.h
@@ -126,7 +126,7 @@ static inline struct pmenu *pmenu_from_scr(struct nc_scr *scr)
 
 static inline void pmenu_dump_item(const ITEM *item)
 {
-       pb_debug("%p %s\n", item, (item ? item->name.str : "(null)"));
+       pb_debug("%p %s\n", item, (item ? item_name(item) : "(null)"));
 }
 
 static inline void pmenu_dump_items(ITEM *const *items, unsigned int count)
@@ -135,7 +135,7 @@ static inline void pmenu_dump_items(ITEM *const *items, unsigned int count)
 
        for (i = 0; i < count; i++)
                pb_debug("%u: %p %s\n", i, items[i],
-                       (items[i] ? items[i]->name.str : "(null)"));
+                       (items[i] ? item_name(items[i]) : "(null)"));
 }
 
 #endif

However then it fails in another place, where petitboot tries to write to items[i]->name.str. Apparently there is no setter function for it in ncurses and a new label would need to be created instead (?) - I didn't look into it in detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant