更新后的 wxDevCpp 中的 BGI 不起作用

BGI in updated wxDevCpp does not work

本文关键字:BGI 不起作用 中的 wxDevCpp 更新      更新时间:2023-10-16

我需要在我的程序中使用BGI图形,它在wxDevCpp 7.3中运行良好。但是现在我安装了这个 IDE 7.4 的更新版本,像以前一样 http://www.cs.colorado.edu/~main/bgi/dev-c++/指令执行所有操作,但现在当我尝试编译任何简单的程序时,例如

#include <graphics.h>
int main( )
{
    initwindow(400, 300, "First Sample");
    circle(100, 50, 40);
    while (!kbhit( ))
    {
        delay(200);
    }
    return 0;
}

我收到多个错误,说

initwindow(), circle(), kbhit(), delay()

未在范围内声明。我不知道该怎么办。更新后的wxDevCpp的变化是不同的文件夹结构,但我将graphics.h和libbgi.a复制粘贴到几个文件夹中。我没有忘记按照说明添加链接器命令,但它不起作用。另外,我发现了另一个图形.h,它伴随着新的wxDevCpp的安装,虽然它可能会带来冲突,所以我只是删除了它。:(无变化

我想我解决了!这实际上是图形的问题。当我将所有 graphics.h 复制粘贴到我的.cpp中时,编译器给出了一个错误,即在以下代码中声明了两次 int right:

void printimage(
    const char* title=NULL, 
    double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
    int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
    bool active=true, HWND hwnd=NULL
    );

重新定义int right,因此它只是一个原型,我将其更改为:

void printimage(
    const char* title=NULL, 
    double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
    int left=0, int right=0, int=INT_MAX, int bottom=INT_MAX,
    bool active=true, HWND hwnd=NULL
    );

现在它起作用了!!