problem with gcc or with my brain
Hi Folks !
I have a problem with a source witch do not compile right.
Compiler is gcc on an embedded system.
I think the examples #2 & #3 must be generate the same code,
but the gcc donīt like it :-(
Gcc aborts with the error : invalid use of non-lvalue array
I need the function call like the example #3.
Can me help someone, please !!!
this is the source:
void join(char *strings[],char *dest,int num)
{
int i;
for (i=0;i<num;i++)
dest=strcpy(dest,strings[i])+strlen(strings[i]);
}
void test(void)
{
char *string2="Var2",joined[80];
char *this_works[]={"Const1",string2,"Const3"};
join((char *[]{"Const1","Const2","Const3"},joined,3); /* #1 */
join(this_works,joined,3); /* #2 */
join((char *[]){"Const1",string2,"Const3"},joined,3); /* #3 */
}