On Tue, Feb 24, 2026 at 05:55:57PM -0500, Bill Gray wrote: > I've a feeling I'm being stupid here, but... > > The Fine Manual tells me, at > > https://invisible-island.net/ncurses/man/new_pair.3x.html > > that the find_pair(), alloc_pair(), free_pair() functions are "specific > to ncurses... It is recommended that any code depending on them be > conditioned using NCURSES_VERSION."
fwiw, I see there are 32 pages with that advice > However, it doesn't say with which version this was added. It'd help if > the above said something along the lines of "should be conditioned on > NCURSES_VERSION >= 5", or something like that (dunno with which version it > was introduced, or if indeed the presence of the functions can be determined > that way.) That was in ABI 6 (NCURSES_VERSION >= 6). https://invisible-island.net/ncurses/NEWS.html#index-t20170311 tells me that NCURSES_PATCH was 20170311 at that point. So... #if defined(NCURSES_PATCH) && NCURSES_PATCH >= 20170311 would be precise. Most people could just test NCURSES_VERSION :-) On the other hand, MacOS has ncurses 6, but the header says 20150808, (checking a local machine) so portable code should also check NCURSES_PATCH. curses.h has the compile-time stuff (quoting from Debian 13): /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 6 #define NCURSES_VERSION_MINOR 5 #define NCURSES_VERSION_PATCH 20250216 and I added curses_version as well as -V options long ago, for sanity checks. But the conditioned-on verbiage in the man pages came from Eric, and I had found no reason to make it more complicated. > I have a few test programs that use these functions, both with ncurses > and PDCursesMod/PDCurses (both of which also supply these functions). I'd > like to have those programs start with, say, > > #if defined( __PDCURSES__) || NCURSES_VERSION >= 5 > (we've got the functions; main body of test code) > #else > void main( void) > { > fputs( stderr, "Sorry, no new_pair() functions\n"); > } > #endif > > More generally, it'd be nice to be able to test for the availability of > the various ncurses extensions when compiling. I generally do that in configure scripts (when I remember...) > If one has the ncurses sources, you can look in ncurses_cfg.h for > HAVE_ALLOC_PAIR. (Which is what the ncurses demos use.) But I'd like a > solution that would work for the more common case where the libraries and > headers are installed, but not the source. The header file is the place to look, along with NEWS to see when a feature was added (usually complete, and easier to work with than looking through the source history). -- Thomas E. Dickey <[email protected]> https://invisible-island.net
signature.asc
Description: PGP signature
