2

I'm trying to compile the following code using the MPLAB C18 v3.36 compiler.

Compiler returns a syntax error on 'char rij;'. But when i put char rij; a line earlier (before TRISA = ...), it compiles ...

void setup(void)
{
 TRISD = 0b00000000;
 TRISA = 0b00000000;
 char rij;
 for (rij = 0; rij<ROWS; rij++)
 {
 red_byte_array[rij]=0;
 green_byte_array[rij]=0;
 blue_byte_array[rij]=0;
 }    
}
TimothyP
  • 21,178
  • 26
  • 94
  • 142
Joost
  • 43
  • 4

1 Answers1

8

Although I'm not familiar with this compiler I would guess that it follows C89 semantics which forbid mixing declarations with statements. Therefore you can only declare variables on the beginning of the block.

Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151
  • a.k.a: put the `char rij` at the top of the function. – zdav Oct 19 '10 at 17:39
  • 1
    This guess is correct — the best boast on the compiler's web page (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010014), is "ANSI '89 compatibility". So no mingling of declarations and code, possibly no // comments (though it was a common extension long before C99) and various other changes you're less likely to trip over with common C code. – Tommy Oct 19 '10 at 17:40