Dscanner: intentionally unused variable

Basile B. b2.temp at gmx.com
Sun Jan 7 08:46:40 UTC 2018


On Sunday, 7 January 2018 at 00:18:27 UTC, Ivan Trombley 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?

You can disable the "unused variable check" for the module in the 
dscanner.ini file located in the project directory see 
https://github.com/dlang-community/D-Scanner#selecting-modules-for-a-specific-check.

More simple is to understand D-Scanner limitations and accept 
that warnings are only warnings and that a message doesn't 
necessarily mean that there's something to do.


More information about the Digitalmars-d mailing list