tags:

views:

71

answers:

1

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;
 }    
}
+7  A: 

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.

Let_Me_Be
a.k.a: put the `char rij` at the top of the function.
zdav
Tommy