运行 并在 Eclipse 的 Mac 终端中使用 ncurses.h 编译 C 程序

Run and compile C program using ncurses.h in Mac Terminal from Eclipse

我正在使用 CDT 8.6.0 for Eclipse Luna 和 OS X Yosemite 而不是 运行 在 Eclipse 的控制台中运行我的程序我想在 Eclipse 的 Mac 终端应用程序中执行此操作。

我已按照以下说明进行操作:Launch terminal from eclipse。有了它们,我设法在一个新的终端 window 中打开了我的项目目录,但它没有编译 运行 我的程序,它只有一个源文件 (main.c)。

我想我没有使用正确的参数,¿你能帮帮我吗?。我刚开始使用终端,我不太确定我在做什么...

程序就是这么简单:

#include <ncurses.h>

int main() {
    initscr();
    printw("Hello World!");
    refresh();
    getch();
    endwin();

    return 0;
}

这是我第一次使用 ncurses 库,当我编译并 运行 程序直接从终端运行时,它工作正常,但是当我在 Eclipse 的控制台中运行时,它似乎工作但也显示输出前的一堆不应该出现的字符...

很高兴阅读您的建议,提前致谢!

默认的Eclipse终端不支持ANSI转义;这个问题之前在 Support ANSI terminal color escape sequences in XML?, indicating that there is a plugin which may help (see Eclipse plugin – ANSI Escape in Console).

中被问过