ncurses.h 库中使用 xcode 的 initscr() 函数错误

error of initscr() function in ncurses.h library using xcode

我们正在尝试使用 ncurses 库来构建终端游戏。 initscr() 函数以某种方式 returns 一条没有额外信息的错误消息。 我们不确定为什么 initscr() 会抛出错误,以及我们应该如何调试它。

TerminalView::TerminalView(ViewModel* vm) {
this->vm = vm;
this->col_size = vm->get_col_size();
this->row_size = vm->get_row_size();
this->player_pos = vm->get_player_pos();
this-> enemy_pos = vm->get_enemy_pos();
this-> projectilePos = vm->getProjectilePos();

//initialize ncurses status
clear();
initscr();
noecho();
cbreak();
keypad(stdscr, TRUE);
curs_set(0);
}

我怀疑 clear()(调用 wclear(stdscr))在创建之前就使用了 stdscr。在我最新的 ncurses 项目中,我捕获了以下评论(不确定来自何处):

   // To initialize the curses, the routine initscr() or
   // newterm() must be called before any of the other routines
   // that deal with windows and screens are used.  The routine
   // endwin() must be called before exiting. 

尝试注释掉 "clear()",我认为你不需要它,因为它有时是 ncurses 做得太多的烦人事情之一。