Here is the piece of code that I am getting error, SDL_Rect’s definition is copied over from documentation:
typedef struct{
Sint16 x, y;
Uint16 w, h;
} SDL_Rect;
SDL_Rect clips[4];
clips[0].x = 0;
clips[0].y = 0;
clips[0].w = 100;
clips[0].h = 100;
Here is how I am compiling it:
gcc -march=native -static-libgcc -o sprite sprite.c functions.o -L/usr/lib -lSDL -lpthread -lm -ldl -lpthread -lSDL_image
Here is the error that I am getting: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token for each line of clips[..] . I have tried putting paranthesis around clips[..] but It didn’t work either. This is plain “C” by the way. Not C++.
Edit
I have copied over SDL_Rect here from SDL’s documentation in order to show what it was. It is not actually in the source file I am using. Therefore, missing of the semicolon cannot be the issue. And this code is in the global scope.
This (-initialisation-) assignment is at global scope which is not possible.
It is possible to initialise the array:
If C99 compliant compiler you can explicitly state the variables being initialised: