27 Apr, 2010, vidar1987 wrote in the 1st comment:
Votes: 0
Hello, to those of you out there that are good coders and good at debugging, I hope you can help me out. I havent been coding for long and Im getting these errors:

act_info.c:2616: warning: assignment discards qualifiers from pointer target type
act_info.c:2617: warning: assignment discards qualifiers from pointer target type
act_info.c:2623: warning: assignment discards qualifiers from pointer target type
act_info.c:2624: warning: assignment discards qualifiers from pointer target type
act_info.c: In function 'do_become':
act_info.c:4241: warning: unused variable 'class2'
act_info.c: In function 'do_score':
act_info.c:1562: warning: 'class2' may be used uninitialized in this function
act_info.c: In function 'do_who':
act_info.c:2450: warning: 'class2' may be used uninitialized in this function


Here are a few lines above and below 2616 and 2617 (I believe its the do_who command)

if ( IS_SET(wch->act, PLR_STORY))
class = "{BStr";

else if (wch->level > 129 && wch->level < 131)
class = "{YHro";

else if (wch->level > 130 && wch->level < 160)
class = "{rLgd";

else if (wch->level > 159 && wch->level < 170)
class = "{yLdr";

else if (wch->level == 170)
class = "{WG{Dr{Wd";


if(wch->level >= 160)
{
imms[immcount] = wch;
classimm[immcount] = class; ((This is line 2616))
class2imm[mortcount] = class2;
immcount++;
}
else if(wch->level < 160)
{

morts[mortcount] = wch;
classmort[mortcount] = class; ((And this is line 2623))
class2mort[mortcount] = class2;
mortcount++;
}
}

for(indeximm = 0; indeximm < immcount; indeximm++)
{
if(shown == FALSE){
sprintf( buf, "%s", immdisp);
add_buf(output,buf);
shown = TRUE;
}
nwch = imms[indeximm];
myclass = classimm[indeximm];
myclass2 = class2imm[indeximm];


Those are my first set of problems, can anyone help me fix those? I have more, but right now, I really REALLY, need help fixing these. Only other thing that doesnt compile cleanly is a few other issues in act_info.c and act_wiz.c The rest compiles cleanly, so Im assuming these warnings and the others in act_info and act_wiz are whats keeping the mud from booting. Please help me!!!
27 Apr, 2010, Zeno wrote in the 2nd comment:
Votes: 0
Those aren't errors, they are warnings. Are they causing your compile to fail? Are you sure? Warnings don't normally cause the compile to fail.
27 Apr, 2010, Kayle wrote in the 3rd comment:
Votes: 0
Those are warnings. Not errors. They're not going to prevent the mud from compiling or booting.
27 Apr, 2010, Asylumius wrote in the 4th comment:
Votes: 0
Like Zeno and Kayle said, those are warnings. If you're actually unable to compile, try giving us the last few lines of the output from "make", which would likely be the actual errors that caused the compiler to bail and not just the warnings.
27 Apr, 2010, vidar1987 wrote in the 5th comment:
Votes: 0
Yeah, thats what I meant, warnings. No they arent preventing the rest of the code to compile, but I cant boot the mud due to those.
27 Apr, 2010, Zeno wrote in the 6th comment:
Votes: 0
If it compiles, the warnings aren't stopping the MUD from booting.
27 Apr, 2010, Sharmair wrote in the 7th comment:
Votes: 0
Zeno said:
If it compiles, the warnings aren't stopping the MUD from booting.

Though I agree that none of these warning are likely the cause of the MUD not booting, just getting
warning (and no errors) does not mean the code will run fine. The two last warning could point to
problems that could crash the MUD, but probably only if the score or who commands are used.

In the case of the first four warnings, class is probably (correctly) declared as a const char* and
the array elements you are assigning to are char* (non const). The fix for this would be to extend
the use of const back to the arrays. The warnings about class2 can be fixed by removing the one
that is unused and making sure the other two are initialized to a valid value before they are used.
27 Apr, 2010, vidar1987 wrote in the 8th comment:
Votes: 0
Thanks for the tips, although Im just starting at coding, I basically have no idea of how to do any of what your saying Sharmair
27 Apr, 2010, David Haley wrote in the 9th comment:
Votes: 0
It sounds like it might be useful to take a look at some basic C tutorials (they're easy to find with Google) so that you can understand the suggestions that Sharmair is making. They're pretty basic and if you're not following you need to brush up your C skills a little; then you'll be able to make more rapid forward progress.
27 Apr, 2010, Zeno wrote in the 10th comment:
Votes: 0
You need to explain why it isn't booting. What's happening? An error?
27 Apr, 2010, vidar1987 wrote in the 11th comment:
Votes: 0
Zeno, I already posted what its saying and the text I get, also, as I mentioned, no errors, just warnings
27 Apr, 2010, Zeno wrote in the 12th comment:
Votes: 0
You posted warnings during compile. That has nothing to do with booting the MUD. You said you can't boot the MUD. Why?
27 Apr, 2010, Cratylus wrote in the 13th comment:
Votes: 0
those are warnings, not errors
27 Apr, 2010, Exodus wrote in the 14th comment:
Votes: 0
As has been said several times above, warnings don't cause the compiler to halt unless you are using the -Werror (treat warnings as errors) option in your Makefile. I suggest looking at your game's log file and seeing at what point it stops. If that is too vague, you can always use GDB to debug the running process. It looks like you're using a MERC/DIKU type game, so assuming you have a binary (you got it to compile) you can do the following:

1. cd to your source code directory
2. gdb nameofbinary (gdb smaug)
3. cd to your area directory
4. run 4000 (or whatever port you normally run on)

You'll see the entire startup sequence fly by you and it should crash and burn at the point where the problem is. That will at least give you an idea of where to look.
28 Apr, 2010, quixadhal wrote in the 15th comment:
Votes: 0
LOL.

Everyone is pooh-pooing these warnings because they aren't "errors". True, but why does that mean you shouldn't fix them???

Quote
act_info.c:2616: warning: assignment discards qualifiers from pointer target type
act_info.c:2617: warning: assignment discards qualifiers from pointer target type
act_info.c:2623: warning: assignment discards qualifiers from pointer target type
act_info.c:2624: warning: assignment discards qualifiers from pointer target type
act_info.c: In function 'do_become':
act_info.c:4241: warning: unused variable 'class2'
act_info.c: In function 'do_score':
act_info.c:1562: warning: 'class2' may be used uninitialized in this function
act_info.c: In function 'do_who':
act_info.c:2450: warning: 'class2' may be used uninitialized in this function


The first four are our old friend "const char *". Somewhere, you are taking a string that was passed in as a "const" and assigning it to a non-const pointer. That means if something outside the function relies on the string being unchanged, the function may have unintended side effects (since you can now change it). This isn't a garbage error, this is one you should address, which is why the compiler is telling you about it. If you know it doesn't matter, do whatever trick you need to do to avoid the warning. Look at any of the recently updated codebases that compile clean in gcc 4.x for examples. :)

The next three are related. They happened because someone cut-and-pasted code. I can tell, because the do_become() function has a class2 variable that is never used anywhere inside the function, yet it is also in several other functions. Remove the declaration and the compiler won't remind you that you didn't use it. The last two are both instances where class2 is used (displayed, used in a comparison, etc) before anything is assigned to it. Sometimes you assign things as a side-effect, and that's harmless. Sometimes you tried to use it before actually doing anything to it. The compiler doesn't know which, so it warns you. If you know your code is doing what you want, add an initialization to 0, NULL, "", whatever is appropriate for the type, at the declaration. Thus the compiler will stop whining.

It took me 2 minutes to type this. How long did you guys spend saying "Don't worry about it, it's just a warning?"

Now, as some of you did say… those aren't going to directly cause the MUD not to boot. But hey, fix 'em and move on so you can find the real problem without noise.
28 Apr, 2010, Cratylus wrote in the 16th comment:
Votes: 0
jus sayin
28 Apr, 2010, Kayle wrote in the 17th comment:
Votes: 0
quixadhal said:
Everyone is pooh-pooing these warnings because they aren't "errors". True, but why does that mean you shouldn't fix them???


I never said not to fix them. I said they weren't causing his MUD to not boot. Which was the issue at hand.
28 Apr, 2010, David Haley wrote in the 18th comment:
Votes: 0
Quote
It took me 2 minutes to type this. How long did you guys spend saying "Don't worry about it, it's just a warning?"

Well, how long did you spend actually answering the question of why the MUD isn't booting or letting him know how to get more information about that?

I'm not sure why you felt the need to get prissy about this when your post wasn't actually addressing the issue. :smile: Nobody is saying the warnings are "just fine" and should be left there forever. But people are trying to get to the heart of the issue… and apparently our OP doesn't want to do that (which is strange of its own right).
28 Apr, 2010, quixadhal wrote in the 19th comment:
Votes: 0
David Haley said:
Quote
It took me 2 minutes to type this. How long did you guys spend saying "Don't worry about it, it's just a warning?"

Well, how long did you spend actually answering the question of why the MUD isn't booting or letting him know how to get more information about that?

Exodus had already addressed how to get more information about it. I had nothing to add, however I did feel it proper to educate the OP about the warnings he obviously was concerned about, rather than handwaving them aside as unimportant.
David Haley said:
I'm not sure why you felt the need to get prissy about this when your post wasn't actually addressing the issue. :smile: Nobody is saying the warnings are "just fine" and should be left there forever. But people are trying to get to the heart of the issue… and apparently our OP doesn't want to do that (which is strange of its own right).

Actually, lots of people implied just that. Perhaps you've forgotten what it's like to not know everything, but if the OP didn't realize that a warning isn't critical to his issue, hearing a bunch of experts say "Don't worry about those, look into this instead" pretty much DOES say to leave them there forever.

Sharmair did point out what I did as well, but the OP seemed to want a bit more detail since, again, they're just starting out. I encourage people to ask WHY instead of just HOW, and on rare occasions I can actually answer that.

If that's being "prissy", ok. :)
28 Apr, 2010, David Haley wrote in the 20th comment:
Votes: 0
Perhaps people are reacting to the fact that the question is:
"Woah my MUD won't boot look at this compiler output"
by educating the poster on the difference between compiler output and the MUD boot sequence.

So the point here is not about warnings, it's about understanding the difference between compilation and execution…
0.0/34