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

时间:2016-04-16 21:16:16

标签: c++ xcode terminal ncurses

我们正在尝试使用ncurses库来构建终端游戏。 initscr()函数以某种方式返回错误消息,没有额外的信息。 我们不确定为什么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);
}

1 个答案:

答案 0 :(得分:1)

我怀疑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做的太多的有时令人烦恼的事情之一。