06 Oct, 2009, Max7288 wrote in the 1st comment:
Votes: 0
So interesting thing, I've been running my mud fine for quite a while now and all of a sudden this new error pops up and its got me stumped..

dg_comm.c: In function 'sub_write':
dg_comm.c:142: error: invalid lvalue in assignment
dg_comm.c:158: error: invalid lvalue in assignment
dg_comm.c:159: error: invalid lvalue in assignment

Line 142: find_invis ? get_char(name) : get_char_room_vis(ch, name);
Line 158: (obj = get_obj_in_list_vis(ch, name, ch->carrying)));
Line 159: (obj_data *)otokens= obj;
06 Oct, 2009, Zeno wrote in the 2nd comment:
Votes: 0
Sounds like your host upgraded gcc.

(obj_data *)
should be
(obj_data) *
06 Oct, 2009, Max7288 wrote in the 3rd comment:
Votes: 0
Okay so i tried that and it didnt work.. here are the parts where those code lines come from

/* get char_data, move to next token */
type[i] = *p;
*s = '\0';
p = any_one_name(++p, name);
(char_data *)otokens[i] =
find_invis ? get_char(name) : get_char_room_vis(ch, name);
tokens[++i] = ++s;
break;

/* get obj_data, move to next token */
type[i] = *p;
*s = '\0';
p = any_one_name(++p, name);
(obj_data *)otokens[i] =
find_invis ? (obj = get_obj(name)) :
((obj = get_obj_in_list_vis(ch, name,
world[IN_ROOM(ch)].contents)) ? obj :
(obj = get_object_in_equip_vis(ch, name,
ch->equipment, &tmp)) ?
obj :
(obj = get_obj_in_list_vis(ch, name, ch->carrying)));
(obj_data ) * otokens[i] = obj;
tokens[++i] = ++s;
break;
06 Oct, 2009, Zeno wrote in the 4th comment:
Votes: 0
(obj_data *)otokens[i] =

Doesn't look fixed to me.
06 Oct, 2009, Max7288 wrote in the 5th comment:
Votes: 0
When i put the * out side the () brackets it gave me this in the compiler

dg_comm.c:151: warning: dereferencing 'void *' pointer
dg_comm.c:151: error: void value not ignored as it ought to be
06 Oct, 2009, David Haley wrote in the 6th comment:
Votes: 0
What is otokens declared as?

(Why oh why do people write code that does things like that? Sigh…)
06 Oct, 2009, Max7288 wrote in the 7th comment:
Votes: 0
dg_comm.c: void *otokens[], char type[])
dg_comm.c: if (!otokens)
dg_comm.c: else if ((char_data *)otokens== ch)
dg_comm.c: strcat(sb,PERS((char_data *)otokens, ch));
dg_comm.c: if (!otokens)
dg_comm.c: else if ((char_data *)otokens== ch)
dg_comm.c: strcat(sb,PERS((char_data *) otokens, ch));
dg_comm.c: if (!otokens|| !CAN_SEE(ch, (char_data *) otokens))
dg_comm.c: else if (otokens== ch)
dg_comm.c: strcat(sb,HSHR((char_data *) otokens));
dg_comm.c: if (!otokens|| !CAN_SEE(ch, (char_data *) otokens))
dg_comm.c: else if (otokens== ch)
dg_comm.c: strcat(sb,HSSH((char_data *) otokens));
dg_comm.c: if (!otokens|| !CAN_SEE(ch, (char_data *) otokens))
dg_comm.c: else if (otokens== ch)
dg_comm.c: strcat(sb,HMHR((char_data *) otokens));
dg_comm.c: if (!otokens)
dg_comm.c: strcat(sb,OBJS(((obj_data *) otokens), ch));
dg_comm.c: void *otokens[MAX_INPUT_LENGTH];
dg_comm.c: (char_data *)otokens=
dg_comm.c: (obj_data ) * otokens=
dg_comm.c: (obj_data ) * otokens= obj;
dg_comm.c: sub_write_to_char(ch, tokens, otokens, type);
dg_comm.c: sub_write_to_char(to, tokens, otokens, type);

Everything with otokens in my files, Note this isnt my Codebase im just trying to patch it up while me and my other coders make one from scratch
06 Oct, 2009, David Haley wrote in the 8th comment:
Votes: 0
First off you need to be careful with in your posts, because as you can see it all gets wonky and the '' indicators go away.
Secondly you should be using code tags. Note that code tags fix the problem (see below).

Anyhow, what you want is something like this:

otokens[i] = (void*) obj;
06 Oct, 2009, Max7288 wrote in the 9th comment:
Votes: 0
I didn't see anything like that, I grep'd for otokens and thats all the results i got for it..
Maybe thats the reason why its messed up?
06 Oct, 2009, Max7288 wrote in the 10th comment:
Votes: 0
06 Oct, 2009, David Haley wrote in the 11th comment:
Votes: 0
No, I mean, you should use that as your assignment, instead of the weirdness that the code is doing.
06 Oct, 2009, Max7288 wrote in the 12th comment:
Votes: 0
Oh okay i'll try it out, Thanks
06 Oct, 2009, Max7288 wrote in the 13th comment:
Votes: 0
Well i tried what you suggested and its still giving me this error when i go to compile..
error: invalid lvalue in assignment for these lines

(char_data *)otokens[i] = (void*) obj;

(obj = get_obj_in_list_vis(ch, name, ch->carrying)));

(obj_data *)otokens[i] = (void*) obj;
06 Oct, 2009, David Haley wrote in the 14th comment:
Votes: 0
(char_data *)otokens[i] = (void*) obj;

becomes
otokens[i] = (void*) obj;


Don't know what to do here since more context is needed:
(obj = get_obj_in_list_vis(ch, name, ch->carrying)));



(obj_data *)otokens[i] = (void*) obj;

becomes
otokens[i] = (void*) obj;




The point of the changes is that you shouldn't be casting the left-hand side, but should be casting the right-hand side of the assignment.
06 Oct, 2009, Max7288 wrote in the 15th comment:
Votes: 0
/* get obj_data, move to next token */
type[i] = *p;
*s = '\0';
p = any_one_name(++p, name);
(obj_data *)otokens[i] =
find_invis ? (obj = get_obj(name)) :
((obj = get_obj_in_list_vis(ch, name,
world[IN_ROOM(ch)].contents)) ? obj :
(obj = get_object_in_equip_vis(ch, name,
ch->equipment, &tmp)) ?
obj :
(obj = get_obj_in_list_vis(ch, name, ch->carrying)));
otokens[i] = (void*) obj;
tokens[++i] = ++s;
break;


Thats the full part of the code for the one you said you needed more info on it
06 Oct, 2009, David Haley wrote in the 16th comment:
Votes: 0
OK, same thing then. Cast the right-hand side to void*, don't cast the left-hand side at all.
06 Oct, 2009, Max7288 wrote in the 17th comment:
Votes: 0
in which part exactly cause the "problem line" doesn't have Void* in it
(obj = get_obj_in_list_vis(ch, name, ch->carrying)));


Sorry im a bit groggy from fighting a flu :(
06 Oct, 2009, Max7288 wrote in the 18th comment:
Votes: 0
Guess im still not advanced enough to understand casting or im just too doped up on flu meds to not understand atm lol :(
06 Oct, 2009, Max7288 wrote in the 19th comment:
Votes: 0
Also i was thinking wouldn't
otokens[i] = (obj_data *) obj;

Work also instead of *void?
06 Oct, 2009, Max7288 wrote in the 20th comment:
Votes: 0
Nevermind it finally clicked in my head. I've got it all worked out now.. Thanks
0.0/21