I am trying to compile the following code in MPLab v5.10 using XC8 for a PIC18.
The code is as follows:
struct vec2i {
int x;
int y;
};
void main(void) {
static struct vec2i array[10];
int i;
for(i = 0; i < 10; ++i) {
array[i] = {0, 0};
}
return;
}
This yields the following error:
newmain.c:11:20: error: expected expression
array[i] = {0, 0};
This code compiles just fine on my native gcc compiler.
If I change the code to the following, the error goes away.
struct vec2i {
int x;
int y;
};
void main(void) {
static struct vec2i array[10];
int i;
for(i = 0; i < 10; ++i) {
// array[i] = {0, 0};
array[i].x = 0;
array[i].y = 0;
}
return;
}
I am using the free version of XC8, version 2.05. Is this a bug, or am I overlooking something with regards to the PIC architecture?