GP32 Totally Lost On Arrays :(


CrazyDesi

Member
Joined
Apr 13, 2004
Messages
446
Ok I am having problems with this code:

Code:
typedef struct
{
u16 x;
u16 y;
unsigned char sprite[];
}Sprites;
 
Sprites image[19];
 
image[1].sprite[]=barS[];

barS in this is just a .bmp converted to .c for Mirkos SDK.

If I do this:

Code:
typedef struct
{
u16 x;
u16 y;
unsigned char sprite[];
}Sprites;
 
Sprites image[19];
 
image[1].sprite=barS;

I get invalid use of flexible array member. Anyone able to help me :(.
 
Yes, replace
Code:
unsigned char sprite[];
with
Code:
unsigned char *sprite;
and the ending line would then be
Code:
image[1].sprite = (unsigned char *) barS;

Anyway, this may help if the barS array is defined as static.
It works for me this way, but I use my own converter and never
seen Mirko's SDK.
 
Code:
typedef struct
{
u16 x;
u16 y;
unsigned char * sprite[];
}Sprites;

Sprites image[19];

image[1].sprite=*barS;

Code:
typedef struct
{
u16 x;
u16 y;
unsigned char * sprite[];
}Sprites;

Sprites image[19];

image[1].sprite=&barS;

Those 2 do not work. I didn't do the typecast because its already an unsigned char. Here is the code for the barS. Its basically a paddle for a pong clone. Anyway here it is:

http://www.rafb.net/paste/results/SL3WtX95.html
 
Right after you posted I got it solved. RoberJ and general helped me out. Thanks to the both of them :).
 
Back
Top