Use <curses.h>
, read the header file to see which definition you prefer using:
/*
* With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or
* conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is
* not already defined, e.g., if the platform relies upon nonstandard feature
* test macros, define it at this point if the standard feature test macros
* indicate that it should be defined.
*/
#ifndef NCURSES_WIDECHAR
#if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
#define NCURSES_WIDECHAR 1
#else
#define NCURSES_WIDECHAR 0
#endif
#endif /* NCURSES_WIDECHAR */
(just NCURSES_WIDECHAR
should be enough). This is summarized in the manual page.
If you read cursesw.h
, you might notice that it is for the C++ binding.
As suggested in another answer, you can get some help from the pkg-config program. However, that gives different results for Arch Linux:
$ pkg-config ncurses --cflags --libs
-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lncursesw
$ pkg-config ncursesw --cflags --libs
-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -lncursesw
That is, the Arch Linux packager has equated the two configurations of ncurses; both selections in pkg-config
use the ncursesw
library. The Arch Linux package does have a libncurses.so
, but that is only a text-file telling the linker to use libncursesw.so
. Because of the way it is packaged, on Arch Linux it makes no difference which library you use.
(offhand, combining _GNU_SOURCE
and _DEFAULT_SOURCE
is incorrect, probably not from any distribution's packaging system, because the former was deprecated in ncurses five years ago).