10 Jul, 2015, Tijer wrote in the 1st comment:
Votes: 0
Today i updated my server to gcc 4.9.2 - We needed to update the release of the OS as it was no longer supported, and this is the version of gcc that we were upgraded to….

Now im getting various warnings in the code, and i HATE having warnings on compile.

olc.c: In function room_damage_edit:
olc.c:1273:23: warning: variable pRoom set but not used [-Wunused-but-set-variable]

Is anyone able to assist in the fixing of this? i have tried numerous things. And nothing is working.. i understand the meaning of the warnings… the variable is unused but being set, but in this particular function pRoom is needed for OLC reasons…

The MUD still compiles… and runs…
10 Jul, 2015, khyldes wrote in the 2nd comment:
Votes: 0
Take out unused-but-set-variable in your Makefile, something like -Wno-unused-but-set-variable
10 Jul, 2015, Tijer wrote in the 3rd comment:
Votes: 0
that worked thanks… strangely when i tried that earlier it didnt… :rolleyes:
10 Jul, 2015, quixadhal wrote in the 4th comment:
Votes: 0
Or, fix the cause of the warning…. If you really aren't using the variable, why keep it in there? If you're playing pointer tricks, stop doing that. :)
10 Jul, 2015, Skol wrote in the 5th comment:
Votes: 0
I was going to say remove the pointer, as with unused variables… if they have no purpose (ie re-written code doesn't use them), yank them and move on :).
11 Jul, 2015, Tijer wrote in the 6th comment:
Votes: 0
the point i was trying to make was these warnings didnt exist when i compiled with the older version of gcc.. so are they really issues?
11 Jul, 2015, quixadhal wrote in the 7th comment:
Votes: 0
Well, each new version of a compiler highlights more "suspect" code than the previous one did.

A compiler is like any other piece of software. It has bugs. It is inefficient. And it has a set of features. When you see new warnings show up, that's typically because the people writing the compiler added a new feature.

Very simple compilers (and ones early in their development cycle) concentrate on bugs and efficiency, making a straight-forward translation from source code to assembly language (or directly to object code) with no real analysis being done. As the compiler gets mature, the developers naturally try to analyze the source code (and resulting object code) to spot places they can optimize or improve results. That same analysis often results in spotting patterns of input in the source code that lead to inefficient or buggy results.

In this particular case, they've found a variable which you set but never directly used. This usually means either you later created a pointer to it and then passed that pointer in for use, rather than just using the address of the original variable…. OR… you cut/pasted it from elsewhere and removed whatever code used to make use of it. In the first case, you can just pass the address directly and avoid keeping an extra pointer hanging around. In the second case, it's just wasted space that has to be allocated by the compiler and then never used.

I've had cases where compiler warnings resulted in me finding subtle bugs in perfectly valid code, but invalid logic.