Search code examples
c

Syntax error found int expecting ; C ICC12 Compiler


I have the following code

#include <hcs12dp256.h>

void spinloop(int spins)
{
 for (int i=0; i<spins; i++)
 {
  i ++;
 }
}

void main(void)
{
 DDRK = DDRK & 0x0F;
 PORTK = PORTK & 0x00;

 PORTK = PORTK | 0x01;
 PORTK = PORTK | 0x02;

 spinloop(100000);

 PORTK = PORTK & 0x0C;
 PORTK = PORTK | 0x03;
 PORTK = PORTK | 0x04;
}

When I go to compile it I'm getting loads of errors, mainly around the for loop. I'm getting the following error on line 5

Syntax error found int expecting ;

followed by

Syntax error found int expecting )
Skipping int

I'm not quite sure what the issue is, I'm fairly new to this coding so I may simply be missing something simple.

Any help would be greatly appreciated.

Thanks


Solution

  • Change:

    for (int i=0; i<spins; i++)
    

    with

    int i;
    for (i=0; i<spins; i++)
    

    Your compiler probably doesn't support C99.