gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 05:43:30 24 4
gpt4 key购买 nike

我们正在尝试使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com