Message-ID: <20010320223103.87893.qmail@web13301.mail.yahoo.com> Date: Tue, 20 Mar 2001 14:31:03 -0800 (PST) From: Rafael Frongillo Subject: parse error before class definition To: djgpp AT delorie DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Reply-To: djgpp AT delorie DOT com Hello I am writing a program that uses class declaration and inheritance, the latter of which shouldn't really influence to my problem. When I compile the following files (actually the last one that I am sending), I get an error that says "walls.h:8: parse error before `{'". I know what a parse error is, but I can't see where I messed up, or if I did. I tried installing the compiler again, renaming the file, putting a semi-colon before the file, and other exotic attemps at solving the problem, but all for naught. Please tell me what I should do. Thanks! -Rafael Frongillo ***The problem file: #ifndef WALLS_H #include #include #include #include "guy.h" class wall { //walls.h:8: parse error before `{' public: wall(); wall(int x, int y, int w, int h, int u, int d, int l, int r, int t); void draw(int b); int check(int x, int y, BITMAP *chpic); int check(int &xx, int &yy, int ww, int hh, int &dd); int checkg(int &gx, int &gy, int gw, int gh, int dir3d); void destroy(); int x,y,w,h,up,dn,lf,rt,typ,fake; }; wall walls[MAXWALL]; #define WALLS_H #endif ***The file it #includes: #ifndef GUY_H #include #define RT 1 #define LF -1 #define UP 2 #define DN 3 #define FD 4 #define FB 0 #define FF -1 #define F1 1 #define F2 2 #define F3 3 #define w1 -2 #define w2 -3 #define W1 11 #define W2 12 #define W3 13 #define EX 100 #define XF 101 #define XN 102 #define DD 89 #define D0 90 #define D1 91 #define D2 92 #define D3 93 #define D4 94 #define D5 95 #define D6 96 #define D7 97 #define D8 98 #define D9 99 #define MAXWALL 200 #define MAXDOOR 10 #define MAXMSL 10 #define MAXLEV 2 #define G1 0 #define B1 1 #define GH 14 #define GW 25 struct MSL { int x,y,w,h,d,typ,range,pn,dx,dy,exp; BITMAP *chpic; }; int wallgrid[MAXLEV][GH][GW] = { {{FB,FB,FB,FB,FB, FB,FB,FB,FB,FB, FB,FB,FB,FB,FB, FB,FB,FB,FB,FB, FB,FB,FB,FB,FB }, { W1,F1,FF,F1,F1, F1,F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F1,FB,FB,F1, F1,F1,F1,F1,F1, FF,F1,FB,FB,F1 }, { w2,FB,FF,W2,FB, FB,FB,W1,FB,W1, F1,W1,FB,FB,w2, FB,FB,W1,FB,w1, F1,W1,FB,FB,W2 }, { W2,F1,FF,W2,F1, F1,F1,F1,FB,F1, F1,FB,F1,F1,W1, F1,F1,FB,FB,F1, F1,F1,F1,F1,W2 }, { W2,F1,FF,W2,FB, F1,F1,W2,FB,F1, F1,FB,FB,FB,XF, F1,FB,FB,F1,F1, F1,F1,FB,F1,w2 }, { W1,F1,F1,W1,FB, F1,FB,W1,F1,W1, F1,W1,FB,FB,W2, FB,FB,W1,FB,W1, F1,W1,F1,F1,W1}} }; int doorgrid[MAXLEV][MAXDOOR][2] = { //type, dest (index) {{ D1, 1 }, { D1, 3 }, { EX, EX }, { D1, 4 }, { D1, 0 }} }; int bgs[11][10] = { { 11 }, { G1,0,0,5,1,1 }, { G1,40,0,6,1,1 }, { G1,50,0,5,1,1 }, { G1,80,0,4,1,1 }, { G1,100,0,3,1,1 }, { G1,120,0,7,1,1 }, { G1,200,0,5,1,1 }, { G1,220,0,3,1,1 }, { G1,240,0,6,1,1 }, { G1,300,0,4,1,1 } }; BITMAP *buf, *exitp, *door1, *wallpics, *fswall, *bswall, *ftwall, *btwall, *fplank, *bplank; int wallnum, doornum, scrx, scry, width = GW*30+20, height = GH*88+100;; const int pink = makecol16(255,0,255), white = makecol16(255,255,255), black = makecol16(0,0,0), innerw = 600, innerh = 400, #define GUY_H #endif ***The files that #include the problem file: #include #include #include "walls.h" wall::wall() {} wall::wall(int xx, int yy, int ww, int hh, int uu, int dd, int ll, int rr, int tt) { x = xx; y = yy; w = ww; h = hh; up = uu; dn = dd; lf = ll; rt = rr; typ = tt; switch (typ) { case FF : case w1 : case w2 : fake = 1; break; default : fake = 0; break; } } void wall::draw(int b) { if (scrx-30x && scry-30y) { if (b) { switch (typ) { case F1 : case FF : masked_blit(bplank,buf,0,0,x-5,y-10,bplank->w,bplank->h); break; case w1 : case W1 : masked_blit(bswall,buf,0,0,x-5,y-10,bswall->w,bswall->h); break; case w2 : case W2 : masked_blit(btwall,buf,0,0,x-5,y-10,btwall->w,btwall->h); break; case XF : masked_blit(exitp,buf,0,0,x-5,y-10,exitp->w,exitp->h); break; case D1 : masked_blit(door1,buf,0,0,x-5,y-10,door1->w,door1->h); break; } } else { switch (typ) { case F1 : case FF : masked_blit(fplank,buf,0,0,x-5,y-10,fplank->w,fplank->h); break; case w1 : case W1 : masked_blit(fswall,buf,0,0,x-5,y-10,fswall->w,fswall->h); break; case w2 : case W2 : masked_blit(ftwall,buf,0,0,x-5,y-10,ftwall->w,ftwall->h); break; } }} } int wall::check(int &xx, int &yy, int ww, int hh, int &dd) { if (xx+ww-4>x && xxy && yyx && gx-gw/4y && gyw; i++) { for (int j=0; jh; j++) { if (xx+i>x && xx+iy && yy+j #include #include #include #include "black1.cpp" #include "green1.cpp" #include "bg.cpp" #include "guy.cpp" void reset(); int main() { int delay=5; scrx = 0, scry = 0; PALLETE pall; BITMAP *back1; allegro_init(); install_keyboard(); install_timer(); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0); set_color_conversion(COLORCONV_TOTAL); data = load_datafile("main.dat"); back1 = (BITMAP *)data[BACK1].dat; buf = create_bitmap(width,height); rectfill(buf,0,0,width,height,white); rectfill(screen,0,0,640,480,pink); Green1 green[10] = { Green1(40,100,5,1,1), Green1(40,0,6,1,1), Green1(50,50,5,1,1), Green1(80,0,4,1,1), Green1(100,0,3,1,1), Green1(120,0,7,1,1), Green1(200,80,5,1,1), Green1(220,0,3,1,1), Green1(240,80,6,1,1), Green1(300,88,4,1,1) }; loadIms(); makeWalls(); setBgs(); for (int i=0; i<10; i++) { green[i].dead=0; } generate_332_palette(pall); while (!key[KEY_ENTER] && !dead) { rest(delay); rectfill(buf,scrx-100,scry-100,scrx+innerw+100,scry+innerh+100,white); // blit(back1,buf,0,0,0,0,300,300); drawWalls(1); if (key[KEY_RIGHT] || key[KEY_PGDN]) { d = 1; running = 1; } if (key[KEY_LEFT] || key[KEY_DEL]) { d = -1; running = 1; } if (key[KEY_UP] || key[KEY_HOME]) { if (key[KEY_LSHIFT]) { d = FD; } else if (canjump) { jumping=1; picn=0;} } if (key[KEY_DOWN] || key[KEY_END]) { } if (key[KEY_G]) { if (!godmode) { godmode=1; textout(screen,font,"godmode on ",100,400,pink); } else { godmode=0; textout(screen,font,"godmode off",100,400,pink); } } if (key[KEY_SPACE]) { if (canfire) fire(); canfire=0; } else canfire=1; for (int i = 0; i<10; i++) { if (green[i].dead!=1) { green[i].move(); for (int j=0; j