A
Andreas Lundgren
Hi!
I want to put some values in static memory, and then be able to
reference this data from my code in a decent way by referencing
AllData.Data. (All code beneth is placed outside functions.)
___TYPE___
typedef struct Data_s
{
char* Name_p;
void* Class_p;
int Size
} Data_t;
___DATA___
{"foo", NULL, 0},
{"bar", NULL, 0},
I first tried the following, but when compiling for ARM compiler I've
got "incomplete type is not allowed"
typedef struct AllData_s
{
Data_t Data[];
} AllData_t;
static AllData_t AllData = {
{"foo", NULL, 0},
{"bar", NULL, 0}
};
I then tried the following, but got the same error.
typedef struct Data_t AllData_t[2];
static AllData_t AllData = {
{"foo", NULL, 0},
{"bar", NULL, 0},
};
Finally this worked:
typedef struct Data_t AllData_t[2];
static Data_t AllData[2] = {
{"foo", NULL, 0},
{"bar", NULL, 0},
};
Is is possible to build up more advanced static structures? When I've
got this to work, I directly use the AllData and not the
AllData.Data that I really desired. Would it be possible to do a
more complex data structure at compile time?
Best Regards,
Andreas L - Sweden
I want to put some values in static memory, and then be able to
reference this data from my code in a decent way by referencing
AllData.Data. (All code beneth is placed outside functions.)
___TYPE___
typedef struct Data_s
{
char* Name_p;
void* Class_p;
int Size
} Data_t;
___DATA___
{"foo", NULL, 0},
{"bar", NULL, 0},
I first tried the following, but when compiling for ARM compiler I've
got "incomplete type is not allowed"
typedef struct AllData_s
{
Data_t Data[];
} AllData_t;
static AllData_t AllData = {
{"foo", NULL, 0},
{"bar", NULL, 0}
};
I then tried the following, but got the same error.
typedef struct Data_t AllData_t[2];
static AllData_t AllData = {
{"foo", NULL, 0},
{"bar", NULL, 0},
};
Finally this worked:
typedef struct Data_t AllData_t[2];
static Data_t AllData[2] = {
{"foo", NULL, 0},
{"bar", NULL, 0},
};
Is is possible to build up more advanced static structures? When I've
got this to work, I directly use the AllData and not the
AllData.Data that I really desired. Would it be possible to do a
more complex data structure at compile time?
Best Regards,
Andreas L - Sweden