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

标签 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);
}

最佳答案

我怀疑 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 做太多的令人讨厌的事情之一。

关于c++ - 使用 xcode 的 ncurses.h 库中的 initscr() 函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36669857/

相关文章:

c++ - Qt3D:使用 Qt3DRender::QLayerFilter

c++ - 从链表的结构部分写入二进制文件

linux cd 到包含该文件的文件夹

emacs - 多个 emacs 终端

C++ - 使用默认模板作为特化的基础

c++ - 无法访问传递给 pthread 的结构中的结构元素

ios - 只能在 bitcode 设置为 yes 的情况下上传到 Apple App Store

objective-c - 如何检索 iTunes 上 "Up Next"列表中的轨道

objective-c - 你如何在 Xcode 之外编译和运行 objective-c 文件?

C++程序控制终端窗口