ncursesw functions not declared

旧时模样 提交于 2021-02-11 09:08:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!