Compilers and warnings
if a program compiles and runs as you want but with warnings at compile time why should we take notice of the warnings? just generally wanting to know about reasons for warnings, because some seem very innocuous and especially if you know why they are there, i used to get them from using getch() and then not doing anything with the variable, but getch() was doing what i wanted, ie stopping program.
If you understand why you are getting the warning, then it's sort of OK to ignore it. In the case of using getch() to stop the program and then not using the variable, you can always NOT assign any variable, e.g.
I have worked on projects using "-Werror" in gcc, which means that if there are warnings, it's the same as any error - no object code generated. Warnings are there for a reason. If you understand the reason, then you can, occasionally, ignore the warning.
// instead of
ch = getch();
// That _may_ give you a warning that you are ignoring the result of the function, then use:
hey nice one, i thought you would be first to reply there, what with your signature and all! Yea, i have heard of the compilers where a warning will stop compile, i don't think i would get much work to run if that was the case for me haha, but really, for me its just i like to get rid of the errors as a kind of 'housekeeping' they annoy me messing up my nice little compile report!
are some errors a throwback to where memory was more 'expensive' so unused varialbes or values get flagged?
Sort of, but unused variables are often a sign that you've done something else wrong - e.g. you read in x, but you never use it in the calculation. The compiler is trying to say "well, perhaps you should be using x for something".
err = somefunc(...);
// Oops, we forgot to check err...
I don't recommend ignoring warnings. They're there for a reason. What you should do is strive to understand them and know how to silence them. By silencing them, that (often) means you know how to make it "right."
yes, i don't like to have any errors even if i know why they are there, and i reckon some better programming practices have defo been picked up through learning how to clear them up.
with getch() i seem to remember if i tested the value input with an IF statement, for (Q)uit say, it still gave a warning at compile about a value that is never used, (but to me it is used if the statement is true) i don't remember though, perhaps that one was ok.
I'm pretty sure that's your memory having "bit errors".
Originally Posted by rogster001