问题
I need to use ncurses with unicode support, so I included the following line to my .c file.
#include <curses.h>
In my makefile I'm using -lncursesw as a flag. When calling functions like get_wch(), it tells me "implicit declaration of function". I'm on Arch Linux so I installed ncurses with pacman -S ncurses. In /usr/include I can find cursesw.h, but it doesn't have functions like get_wch() declared. Under /lib I can find libcursesw.so, so what's the matter?
回答1:
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.
来源:https://stackoverflow.com/questions/59971200/ncursesw-functions-not-declared