錯誤:C 函數「int getmaxy(const WINDOW*)」的宣告衝突

錯誤:C 函數「int getmaxy(const WINDOW*)」的宣告衝突

我正在嘗試在我的 Ubuntu 機器上運行以下程序,改編自這個程式, 使用庫圖為BGI功能提供支援:

#include <graphics.h>
#include <curses.h>
int main()
{
    int gd = DETECT, gm, i;
    initgraph(&gd, &gm, NULL);
    int x,y=0,j,t=400,c=1;
    setcolor(RED);
    setlinestyle(0,0,1);
    for(x=40;x<602;x++)
    {
        cleardevice();
        circle(x,y,20);
        floodfill(x,y,YELLOW);
        delay(40);
        if(y>=400)
        {
            c=0;
            t-=20;
        }
        if(y<=(400-t))
            c=1;
        y=y+(c?15:-15);
    }
    getch();
}

它應該輸出一個彈跳球。但是當我編譯它時,我收到以下錯誤:

error: conflicting declaration of C function ‘int getmaxx(const WINDOW*)’
error: conflicting declaration of C function ‘int getmaxy(const WINDOW*)’

我在互聯網上進行了搜索,但仍然無法解決該錯誤。有人能幫助我嗎?

答案1

我建議SDL_bgi對於這種轉換,它似乎比 libgraph 維護得更好。使用它,您需要刪除該#include <curses.h>行(這會導致聲明衝突),並使用

gcc bounce.c -lSDL_bgi $(pkg-config --libs sdl2) -o bounce

相關內容