T
Thorsten Schilling
Hello everybody,
I have the following problem. Consider the following structure:
typedef struct{
unsigned int *msk;
unsigned int **ass;
unsigned int n;
}sym;
Now I would like to initialize an array of this "sym"'s at compile
time. Clearly msk should contain a pointer to e.g. {0x1,0x2,0x3} and
ass to something like {{0x1,0x2,0x3},{0x1,0x2,0x3},{0x1,0x2,0x3}}.
Question is now what is the easiest and most readable way to perform
that.
What doesn't work (or it gives me a warning) like
[...]
../testdata.h:5: warning: braces around scalar initializer
.../testdata.h:5: warning: (near initialization for ‘testdata[0].msk’)
.../testdata.h:5: warning: initialization makes pointer from integer
without a cast
.../testdata.h:5: warning: excess elements in scalar initializer
[...]
is:
static sym testdata[1] = {
{{0x1,0x2},{{0x1,0x2},{0x1,0x2}},3}};
Thanks in advance for any help.
Thorsten
I have the following problem. Consider the following structure:
typedef struct{
unsigned int *msk;
unsigned int **ass;
unsigned int n;
}sym;
Now I would like to initialize an array of this "sym"'s at compile
time. Clearly msk should contain a pointer to e.g. {0x1,0x2,0x3} and
ass to something like {{0x1,0x2,0x3},{0x1,0x2,0x3},{0x1,0x2,0x3}}.
Question is now what is the easiest and most readable way to perform
that.
What doesn't work (or it gives me a warning) like
[...]
../testdata.h:5: warning: braces around scalar initializer
.../testdata.h:5: warning: (near initialization for ‘testdata[0].msk’)
.../testdata.h:5: warning: initialization makes pointer from integer
without a cast
.../testdata.h:5: warning: excess elements in scalar initializer
[...]
is:
static sym testdata[1] = {
{{0x1,0x2},{{0x1,0x2},{0x1,0x2}},3}};
Thanks in advance for any help.
Thorsten