How can I stop "...it's value is never used" warnings from being shown?

How can I stop warnings like this from being shown?

“warning The variable `TOTbaseMapArrays’ is assigned but its value is never used”

I plane on using the variable later and don’t want these warning cluttering my Console in the mean time.

Make a temporary function where those variables are referenced. You would of course not actually use the function, but it will stop the compiler complaining.

–Eric

New in 4.1 you can filter out the warnings, errors, and standard logs with the buttons in the top-right corner of the console.

@Eric5h5 Yeah. That is one way.

Wow. I didn’t know that. I wondered what they were for.
I feel like a dummy.
Thanks.

you can add this to your code

#pragma warning disable ERROR_NUMBER_HERE (without the CS)
CODE HERE
#pragma warning restore ERROR_NUMBER_HERE (without the CS) (in case you want it back for other objects)

more info http://msdn.microsoft.com/en-us/library/441722ys(VS.80).aspx

3 Likes

instead of filtering warnings, i would recommend to remove the variable as long as you don’t need it. these warnings are there for a reason usually.

1 Like

aye, in this case probably to prevent people from leaving old variables behind, cluttering and slowing down code.
or to make it easier to trace your error when having made typing-woes in the variable assignment (though i doubt the latter, haha.)

If someone would have some functions which are used quite often, and one of these functions assigns variables which will never be used, i could imagine it could cost unneeded processing power, which should always be avoided :slight_smile: