Dscanner: intentionally unused variable

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Jan 7 00:22:15 UTC 2018


On Sun, Jan 07, 2018 at 12:18:27AM +0000, Ivan Trombley via Digitalmars-d wrote:
> While working with SDL, I found that I kept using the same pattern over and
> over:
> - Get the current clip rectangle.
> - Set a new clip rectangle.
> - restore the old clip rectangle on scope (exit).
> 
> Instead of writing that code again and again, I wrote a simple
> function that returns a struct which restores the old clip rectangle
> in it's destructor.  This works great but now dscanner complains about
> the variable being unused.
> 
> Is there a way tell dscanner that a variable is intentionally unused?

IMO, dscanner should be fixed to suppress that warning when the variable
in question has a non-trivial dtor that may produce side-effects at the
end of the scope. In such cases, it may be that the whole reason for the
variable is to trigger the dtor's side-effects, as is your case here, so
technically it isn't "unused".


T

-- 
Don't throw out the baby with the bathwater. Use your hands...


More information about the Digitalmars-d mailing list