#2186 this code wont compile

closed-invalid
None
Front-end
5
2013-06-14
2013-06-14
slenk
No

Here is the code that wont compile:

~~~~~~~~~

include <string.h>

include <stdlib.h>

const squareclosed=1;
const squareopen=2;

const pathfound=1;
const pathnotfound=2;
const TargetSquareIsStartSquare=3;
int pathtowalkx[20];
int pathtowalky[20];
int numberofopenlistitems;

char pathresult;
int iter1;
int iter2;

void draw();
char findpath(char startx,char starty,char targetx,char targety);
void clearpath();

struct maptile {
char hcost;
char parentX;
char parentY;
char state;
char occupied;

};

void main(void)
{
struct maptile * maptiles[32][24];
for (iter1=0;iter1<32;iter1++)
{
for(iter2=0;iter2<24;iter2++)
{

maptiles[iter1][iter2]=malloc(sizeof(struct maptile));

}

}

maptiles[1][10]->occupied=1;
pathresult=findpath(1,1,1,10);

while (1)
{

}

}

char findpath(char startx,char starty,char targetx,char targety)
{
clearpath();

if ((startx==targetx)&&(starty==targety))
{
return pathnotfound;
}

struct maptile targetsquare;
targetsquare=*(maptiles[targetx][targety]);

if (targetsquare.occupied==1)
{
return TargetSquareIsStartSquare;
}

//HCost(startx,starty)=GetHCost(startx,starty,targetx,targety)
//AddToOpenList(startx,starty,startx,starty)
//LowestFCostSquareX=startx
//LowestFCostSquareY=starty

return pathnotfound;
}

void clearpath()
{}
~~~~~

This is the command used to compile:
bin/sdcc -mz80 --code-loc 26000 --opt-code-size --std-c99 --no-std-crt0 spec.c

SDCC version used:
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.3.1 #8687 (May 29 2013) (Linux)

here is the error message
spec.c:70: syntax error: token -> 'struct' ; column 6

Discussion

  • Maarten Brock

    Maarten Brock - 2013-06-14

    First, why is only some of the code indented? Did you use TAB's in it?

    Then you should read the manual 3.1.2 ISO C99. It is stated there that SDCC does not support declaration of variables in random places, but only at the start of a block.

     
  • Maarten Brock

    Maarten Brock - 2013-06-14
    • status: open --> closed-invalid
    • assigned_to: Maarten Brock
    • Category: other --> Front-end
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks