ncurses get_wch() 函数未声明
ncurses get_wch() function undeclared
我尝试在 Archlinux 安装上检查 ncurses 库中 get_wch
函数的输出。
但是当我调用这个函数时,我得到了这个 GCC 错误:
main.c:6:15: warning: implicit declaration of function "get_wch";
我按照我的 GCC 命令行建议链接了库:
gcc main.c -lncursesw -o exec
我还检查了是否安装了 ncurses:
core/ncurses 6.2-1 [installed]
multilib/lib32-ncurses 6.2-1 [installed]
当我在“usr/include”目录中列出头文件时,我看到在 lib 编译时生成的头文件允许我使用“widec”函数。
#include <curses.h>
int main() {
initscr();
int test = 0;
int result = get_wch(&test);
printf("Caractère : {} / Function code : {}\n", test, result);
endwin();
return 0;
}
我不明白如何使用这个库。可用的“文档”似乎对我不利...
gcc 警告
main.c:6:15: warning: implicit declaration of function "get_wch";
告诉你get_wch
. X/Open Curses specified all of the wide-character functions conditionally (to avoid breaking old programs). That's summarized in the ncurses manual page没有函数原型:
You must also enable the wide-character features in the header
file when compiling for the wide-character library to use the
extended (wide-character) functions. The symbol which enables
these features has changed since XSI Curses, Issue 4:
Originally, the wide-character feature required the symbol
_XOPEN_SOURCE_EXTENDED
but that was only valid for XPG4
(1996).
Later, that was deemed conflicting with _XOPEN_SOURCE
defined
to 500.
As of mid-2018, none of the features in this implementation
require a _XOPEN_SOURCE
feature greater than 600. However,
X/Open Curses, Issue 7 (2009) recommends defining it to 700.
Alternatively, you can enable the feature by defining
NCURSES_WIDECHAR
with the caveat that some other header file
than curses.h may require a specific value for _XOPEN_SOURCE
(or a system-specific symbol).
get_wch
的原型使用 wint_t
(一个可以容纳“宽字符”的整数,例如 Unicode)。 manual page 列出了宽字符 ncursesw 库(和函数原型)中使用的这些类型:cchar_t
, wchar_t
和 wint_t
如果您想使用包含任何这些类型的函数原型,您的程序应该启用该功能。如前所述before,定义NCURSES_WIDECHAR
是最简单的。
我尝试在 Archlinux 安装上检查 ncurses 库中 get_wch
函数的输出。
但是当我调用这个函数时,我得到了这个 GCC 错误:
main.c:6:15: warning: implicit declaration of function "get_wch";
我按照我的 GCC 命令行建议链接了库:
gcc main.c -lncursesw -o exec
我还检查了是否安装了 ncurses:
core/ncurses 6.2-1 [installed]
multilib/lib32-ncurses 6.2-1 [installed]
当我在“usr/include”目录中列出头文件时,我看到在 lib 编译时生成的头文件允许我使用“widec”函数。
#include <curses.h>
int main() {
initscr();
int test = 0;
int result = get_wch(&test);
printf("Caractère : {} / Function code : {}\n", test, result);
endwin();
return 0;
}
我不明白如何使用这个库。可用的“文档”似乎对我不利...
gcc 警告
main.c:6:15: warning: implicit declaration of function "get_wch";
告诉你get_wch
. X/Open Curses specified all of the wide-character functions conditionally (to avoid breaking old programs). That's summarized in the ncurses manual page没有函数原型:
You must also enable the wide-character features in the header file when compiling for the wide-character library to use the extended (wide-character) functions. The symbol which enables these features has changed since XSI Curses, Issue 4:
Originally, the wide-character feature required the symbol
_XOPEN_SOURCE_EXTENDED
but that was only valid for XPG4 (1996).Later, that was deemed conflicting with
_XOPEN_SOURCE
defined to 500.As of mid-2018, none of the features in this implementation require a
_XOPEN_SOURCE
feature greater than 600. However, X/Open Curses, Issue 7 (2009) recommends defining it to 700.Alternatively, you can enable the feature by defining
NCURSES_WIDECHAR
with the caveat that some other header file than curses.h may require a specific value for_XOPEN_SOURCE
(or a system-specific symbol).
get_wch
的原型使用 wint_t
(一个可以容纳“宽字符”的整数,例如 Unicode)。 manual page 列出了宽字符 ncursesw 库(和函数原型)中使用的这些类型:cchar_t
, wchar_t
和 wint_t
如果您想使用包含任何这些类型的函数原型,您的程序应该启用该功能。如前所述before,定义NCURSES_WIDECHAR
是最简单的。