Skip to content

Commit

Permalink
build: Add a test for whether curses.h works.
Browse files Browse the repository at this point in the history
The main thing I intended to test is "stdscr", but it is also useful to
test ncurses functions that might be implemented as macros, such as
refresh() and mvadd_wchnstr().

Signed-off-by: Kang-Che Sung <[email protected]>
  • Loading branch information
Explorer09 committed Oct 25, 2024
1 parent cae7df7 commit 8eac24b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ProvideCurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ in the source distribution for its full text.
*/


// This header is also used in tests by configure, thus conditionally
// including "config.h".
#if defined(HAVE_CONFIG_H)
#include "config.h" // IWYU pragma: keep
#endif

// IWYU pragma: begin_exports

Expand Down
22 changes: 22 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,28 @@ else
[AC_CHECK_HEADERS([term.h], [],
[AC_MSG_ERROR([can not find required term header file])])])
fi

CFLAGS="-I$srcdir $CFLAGS"
# Check for things that might be macros.
# "stdscr" is a macro in ncursest (reentrant version of ncurses).
AC_MSG_CHECKING([whether the curses header works])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include "ProvideCurses.h"
]], [[
keypad(stdscr, 0);
refresh();
#if defined(HAVE_LIBNCURSESW)
{
static cchar_t dummy;
mvadd_wchnstr(0, 0, &dummy, 0);
}
#endif
]])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_FAILURE([there are problems with the curses header])])
CFLAGS=$htop_save_CFLAGS

if test "$enable_static" = yes; then
Expand Down

0 comments on commit 8eac24b

Please sign in to comment.