Thread: Compile Problem - Dev C++

  1. #1
    Registered User Jack_Zepp's Avatar
    Join Date
    Jul 2010
    Posts
    6

    Compile Problem - Dev C++

    Hi everyone!

    I've downloaded some sample programs to study the code, but when I try to compile these programs, its gives me a lot of compile errors. Im using Dev C++ 4.9.9.2

    For what i've searched the problem is not really in the code, but in the IDE I'm using, but i couldnt find anything more deep about. If someone knows why this is happening I'll be very gratefull. Thank you

    One of the codes i've tryed, for a snake game program.
    Code:
    #include<dos.h>
    #include<conio.h>
    #include<graphics.h>
    #include<stdio.h>
    #include<stdlib.h>
    
    #define UP 72
    #define LEFT 75
    #define RIGHT 77
    #define DOWN 80
    #define ESC 1
    #ifdef __cplusplus
    #define __CPPARGS ...
    #else
    #define __CPPARGS
    #endif
    struct SnakeParts{
    int x;
    int y;
    }box[50],target;
    void snake(int ,int );
    void initialize(int,int);
    void interrupt (*prev)(__CPPARGS);
    void interrupt our(__CPPARGS);
    void snakeb();
    int check();
    void Rectangle(int ,int,int,int);
    int
    stop=0,blocks=4,direction=2,size=10,hit=1,snake_color=14,bk=7,target_color
    =4;
    int stage=1,speed=100,point=0;
    void main(){
    int gd=DETECT,gm,x=100,y=100,i=0,j=0;
    char msg[50];
    initgraph(&gd,&gm,"");
    /*animation*/
    prev=getvect(9);
    /* setcolor(bk);
    rectangle(0,0,639,479);
    setfillstyle(SOLID_FILL,bk);
    floodfill(250,250,bk);*/
    initialize(x,y);
    //getch();
    while (1){
    /*setcolor(bk);
    sprintf(msg,"POINT = %3d",point);
    settextstyle(0,HORIZ_DIR,1);
    outtextxy(550,100,msg); */
    switch(direction){
    case 0: j-=size;break;
    case 1: j+=size;break;
    case 2: i+=size;break;
    case 3: i-=size;break;
    }
    setcolor(snake_color);
    snake(x+i,y+j);//,x+15+i,y+15+j);
    delay(speed);
    setcolor(bk);
    snakeb(/*x+i,y+j*/);//,x+15+i,y+15+j);
    setvect(9,our);
    if(stop==1){break;}
    if(check()){break;}
    if(hit==1){
    hit=0;
    target.x=size+size*random(25);
    target.y=size+size*random(20);
    setcolor(target_color);
    setfillstyle(SOLID_FILL,target_color);
    circle(target.x+size/2,target.y+size/2,size/2-1);
    floodfill(target.x+size/2,target.y+size/2,target_color);
    }
    setfillstyle(SOLID_FILL,target_color);
    setcolor(2);
    circle(target.x+size/2,target.y+size/2,size/2-1);
    floodfill(target.x+size/2,target.y+size/2,2);
    /*setcolor(11);
    sprintf(msg,"POINT = %3d",point);
    settextstyle(0,HORIZ_DIR,1);
    outtextxy(550,100,msg);*/
    gotoxy(65,4);
    printf("POINT = %3d",point);
    //delay(3000);
    //cleardevice();
    }
    closegraph();
    }
    void interrupt our(__CPPARGS){
    //if(inportb(0x60)==UP){
    //i=0;j
    switch(inportb(0x60)){
    case UP: if(direction==1)break;direction=0;break;
    case DOWN: if(direction==0)break;direction=1;break;
    case RIGHT: if(direction==3)break;direction=2;break;
    case LEFT: if(direction==2)break;direction=3;break;
    case 15:blocks++;break;
    case ESC: stop=1;break;
    }
    
    (*prev)();
    }
    void snake(int x1,int y1){//,int x2,int y2){
    int k=0;
    //if(getcolor()==15){
    for(k=blocks-1;k>0;k--){
    box[k].x=box[k-1].x;
    box[k].y=box[k-1].y;
    }
    box[0].x=x1;
    box[0].y=y1;
    //}
    //setfillstyle(SOLID_FILL,snake_color);
    for(k=0;k<blocks;k++){
    Rectangle(box[k].x,box[k].y,box[k].x+size,box[k].y+size);
    //floodfill(box[k].x+size/2,box[k].y+size/2,snake_color);
    }
    
    }
    void snakeb(){
    //setfillstyle(SOLID_FILL,bk);
    for(int k=0;k<blocks;k++){
    Rectangle(box[k].x,box[k].y,box[k].x+size,box[k].y+size);
    //floodfill(box[k].x+size/2,box[k].y+size/2,bk);
    }
    }
    void initialize(int x,int y){
    setcolor(bk);
    rectangle(0,0,639,479);
    setfillstyle(SOLID_FILL,bk);
    floodfill(250,250,bk);
    box[0].x=x;
    box[0].y=y;
    for(int i=1;i<blocks;i++){
    box[i].x=x-size*i;
    box[i].y=y;
    }
    /*for(int k=0;k<blocks;k++)
    rectangle(box[k].x,box[k].y,box[k].x+15,box[k].y+15);*/
    }
    int check(){
    int i;
    char msg[50];
    
    if(!(box[0].x>=0 && box[0].x<=639 && box[0].y>=0 && box[0].y<=479)){
    for( i=100;i<700;i+=100){
    sound(i);
    delay(100);
    nosound();
    }
    sprintf(msg,"GAME OVER");
    setcolor(4);
    settextstyle(1,HORIZ_DIR,6);
    outtextxy(150,200,msg);
    delay(3000);
    cleardevice();
    return 1;
    }
    for( i=1;i<blocks;i++){
    if(box[0].x==box[i].x && box[0].y==box[i].y){
    sprintf(msg,"GAME OVER");
    setcolor(4);
    settextstyle(1,HORIZ_DIR,6);
    outtextxy(150,200,msg);
    delay(3000);
    cleardevice();
    return 1;
    }
    }
    if(box[0].x==target.x && box[0].y==target.y){
    //for( i=50;i<400;i+=50){
    sound(700);
    delay(100);
    nosound();
    //}
    blocks++;
    point++;
    hit=1;
    setcolor(bk);
    //circle(target.x+size/2,target.y+size/2,size/2-1);
    setfillstyle(SOLID_FILL,bk);
    setcolor(bk);
    circle(target.x+size/2,target.y+size/2,size/2-1);
    floodfill(target.x+size/2,target.y+size/2,bk);
    }
    if(blocks==40){
    stage++;
    blocks=4;
    sprintf(msg,"STAGE %d CLEARED",stage-1);
    setcolor(4);
    settextstyle(1,HORIZ_DIR,6);
    outtextxy(150,200,msg);
    delay(2000);
    cleardevice();
    initialize(100,100);
    speed=100/stage;
    }
    return 0;
    }
    void Rectangle(int x1,int y1,int x2,int y2){
    for(int i=0;i<size/2;i++)
    rectangle(x1+i,y1+i,x2-i,y2-i);
    }
    Here's the error log:

    Code:
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:23: error: variable or field `interrupt' declared void
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:23: error: `prev' was not declared in this scope
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:23: error: expected `,' or `;' before '(' token
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:24: error: `interrupt' does not name a type
    
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:32: error: `main' must return `int'
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp: In function `int main(...)':
    
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:37: error: `prev' undeclared (first use this function)
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:37: error: (Each undeclared identifier is reported only once for each function it appears in.)
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:37: error: `getvect' undeclared (first use this function)
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:60: error: `our' undeclared (first use this function)
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:60: error: `setvect' undeclared (first use this function)
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:65: error: `random' undeclared (first use this function)
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:80: error: `gotoxy' undeclared (first use this function)
    
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp: At global scope:
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:87: error: `interrupt' does not name a type
    
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp: In function `int check()':
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:145: error: `sound' undeclared (first use this function)
    C:\Documents and Settings\caio.fontes\Desktop\Faculdade - Prog. em C\Snake\snake2.cpp:147: error: `nosound' undeclared (first use this function)
    Last edited by Jack_Zepp; 07-21-2010 at 11:28 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well posting some ACTUAL warning / error messages would be a start...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User Jack_Zepp's Avatar
    Join Date
    Jul 2010
    Posts
    6
    Quote Originally Posted by Salem View Post
    Well posting some ACTUAL warning / error messages would be a start...
    Sorry, I didn't post it at first because I though the problem was not in the code, but on the program I was using to compile it. Already updated it with the code and the error log

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well the problem is this.

    You're trying to compile an ancient DOS program written for something like Turbo-C, using a compiler which is primarily targeted at producing Win32 executables.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User Jack_Zepp's Avatar
    Join Date
    Jul 2010
    Posts
    6
    I see, I suspected it was something like that, thanks a lot!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Starting with Dev C ; a problem
    By mabauti in forum C++ Programming
    Replies: 18
    Last Post: 12-05-2007, 11:16 AM
  2. dev & allegro compile errors
    By Calgore in forum C++ Programming
    Replies: 10
    Last Post: 08-11-2004, 04:41 PM
  3. Help to compile with Dev C++ 5
    By Michty in forum Windows Programming
    Replies: 3
    Last Post: 12-14-2003, 09:22 PM
  4. Dev C++ problem
    By Bluehead in forum Windows Programming
    Replies: 1
    Last Post: 08-21-2002, 05:33 PM
  5. C++ compile problem
    By Rhuantavan in forum C++ Programming
    Replies: 3
    Last Post: 06-15-2002, 03:29 PM