Hi!
Is it possible to inline initialize a struct whose one member is a st=
ring
array of arbitrary length (terminated w/ a NULL ptr)? What I mean is =
something like this:
typedef struct {
char** x ;
int y ;
} Foo ;
static const Foo myfoos[] =3D {
{ { "hello", "world", NULL }, 12 },
{ NULL, 0 }
} ;
This produces warnings (from mingw gcc) for line w/ "hello" on it:
"initialization from incompatible pointer type"
"excess elements in scalar initializer"
"braces around scalar initializer"
So obviously this is not the way to do it, or I am missing something =
=
here? Is
this possible at all?
It works fine if I define the first struct memeber as char* x[ 3 ] ; =
but =
that
is not what I'm after - I need arbitrary length char* arrays.
As a last resort, I can do the initialization in the beginning of mai=
n
(i.e. just myfoos[0].x =3D ptrToFirstStrArray ; // ...), but that's not =
very =
pretty...
.::Antti::.
Ps. I did consider "multistrings", e.g. "hello\0world\0", but that wo=
uld =
be inconsistent w/ the presentation of array of string values used in =
other parts of the program.


|