From: Svein Ove Aas Newsgroups: comp.os.msdos.djgpp Subject: Weird error Date: Fri, 24 Jul 1998 15:32:01 +0200 Organization: Telenor Online Public Access Lines: 88 Message-ID: <35B88CD1.DC1C92C8@online.no> NNTP-Posting-Host: ti33a95-0025.dialup.online.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I have a rather strange error here: My compiler insists that there's a parse error in front of a zero, but there isn't any number at all there. What might be the reason? I use Allegro 3.0, and RHIDE. Here's the source. (Failure point indicated) // Functions for loading menu objects, and displaying menus. #include #include #include "ss.h" #include "datafile.h" void *load_menufile(PACKFILE *f, long size) { int c; C_MENU *tmp=new C_MENU; tmp->numitems = pack_igetw(f); tmp->menudata = new char* [tmp->numitems]; char buf[100]; for (c=0; c <= tmp->numitems; c++) { pack_fgets(buf,100,f); tmp->menudata[c]=new char[strlen(buf)]; strncpy(tmp->menudata[c],buf,strlen(buf)); } return(tmp); } void destroy_menufile(void *menu) { delete menu; } // Here's the menu-view function. int PROGRAM::menu(C_MENU *menu) { int menuchoice = 0; bool no_choice = -1; DATAFILE *backgrounds=load_datafile_object("datafile.dat","backgrounds"); <-----<------< Failure point. BITMAP *buffer=create_bitmap(640,480); BITMAP *bg=(BITMAP *)backgrounds[backgrounds_menu].dat; <---------<---------< Another failure here.(Error: invalid types 'int[int]' for array subscript. text_mode(-1); blit(buffer,bg,0,0,0,0,640,480); const up_start=(menu->numitems*8)+((menu->numitems-1)*8); const down_end=(menu->numitems*8)+((menu->numitems-1)*8); int y; while (no_choice) { y=up_start; for (int index=0; index <= (menu->numitems); index++) { y += 16; if (index==menuchoice) textout_centre (buffer,font,menu->menudata[index],320,y,makecol(255,200,200)); else textout_centre (buffer,font,menu->menudata[index],320,y,makecol(200,40,40)); } vsync(); blit (screen,buffer,0,0,0,0,640,480); switch (readkey() >> 8) { case KEY_UP: menuchoice = menuchoice == 0 ? menu->numitems : menuchoice - 1; break; case KEY_DOWN: menuchoice = menuchoice == menu->numitems ? 0 : menuchoice + 1; break; case KEY_ENTER: no_choice = 0; break; } } vsync(); clear(screen); destroy_bitmap(buffer); }