Windows 11 + GCC 编译器 17 (MINGW2)
gcc -o main.exe main.c -lncursesw ; ./main.exe
C:\msys64\mingw64\include
C:\msys64\mingw64\include\ncurses
C:\msys64\mingw64\include\ncursesw
它只是在窗口周围画了一个边框。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ncurses/curses.h>
#include <wchar.h>
int main()
{
initscr();
int row = 0;
int col = 0;
getmaxyx(stdscr, row, col);
wchar_t * square = L"\u2588";
for (int i = 0; i < row; i++)
{
if (i == 0 || i == row - 1)
{
for (int j = 0; j < col; j++)
{
mvaddwstr(i, j, square);
}
}
else
{
mvaddwstr(i, 0, square);
mvaddwstr(i, col - 1, square);
}
}
refresh();
getch();
endwin();
return 0;
}
编译器似乎认为
mvaddwstr
是隐式声明的。但是,我在编译命令中明确链接了 ncursesw
库(而不是常规的 ncurses
)。
main.c:76:17: warning: implicit declaration of function 'mvaddwstr'; did you mean 'mvaddstr'? [-Wimplicit-function-declaration]
76 | mvaddwstr(i, j, square);
| ^~~~~~~~~
| mvaddstr
尽管有警告,程序运行正常。但是,我还是想解决这个警告。
我试图在代码中包含
curses.h
中的ncursesw
文件。但是,警告仍然存在。
#include <ncursesw/curses.h>
我也试过在编译命令的
ncursesw
目录下添加一个include,但是警告依旧存在
gcc -o main.exe main.c -IC:\msys64\mingw64\include\ncurseswncursesw -lncursesw; ./main.exe