htop-dev / htop

htop - an interactive process viewer
https://htop.dev/
GNU General Public License v2.0
6.16k stars 418 forks source link

htop fails to compile with gcc-14.1 unless ncurses has been built with --enable-sigwinch #1474

Open heitbaum opened 2 months ago

heitbaum commented 2 months ago

The below line causes a failure to compile htop with gcc-14.1 when ncurses has not been built with --enable-sigwinch. https://github.com/htop-dev/htop/blob/4b3dfa246e9fa0fe3ce7d97e7a37239251ada42b/ScreenManager.c#L361-L365

../ScreenManager.c: In function 'ScreenManager_run':
../ScreenManager.c:361:12: error: 'KEY_RESIZE' undeclared (first use in this function); did you mean 'KEY_RESUME'?
  361 |       case KEY_RESIZE:
      |            ^~~~~~~~~~
      |            KEY_RESUME
../ScreenManager.c:361:12: note: each undeclared identifier is reported only once for each function it appears in

Ref:

/*
 * KEY_RESIZE is an extended feature that relies upon the SIGWINCH handler
 * in ncurses.
 */
#if 1
#ifndef NCURSES_SIGWINCH
#define NCURSES_SIGWINCH 1
#endif
#else
#undef NCURSES_SIGWINCH
#define NCURSES_SIGWINCH 0
#endif

...

#if NCURSES_SIGWINCH
#define KEY_RESIZE      0632            /* Terminal resize event */
#endif
fasterit commented 2 months ago

hm, we could #ifdef that. And we could write our own signal handler for sigwinch in case ncurses has been compiled without its own. Or we gracefully complain and exit at the configure stage.