Use this tag when question related to unused variables issues as warnings
Questions tagged [unused-variables]
179 questions
11
votes
1 answer
Eclipse Errors/Warnings ignore assert in unused variable analysis
I have had 'hidden' bugs due to Eclipse not reporting 'unused' variables because they were used in an assertion (precondition), for example:
public void method(final String text, ...other parameters) {
assert StringUtils.isNotBlank(text);
...
…

Christophe Roussy
- 16,299
- 4
- 85
- 85
11
votes
3 answers
boost::system::(...)_category defined but not used
I'm currently getting compiler warnings that resemble the warning I gave in the question title. Warnings such as....
warning: 'boost::system::generic_category' defined but not used
warning: 'boost::system::posix_category' defined but not…

Anonymous
- 4,167
- 11
- 47
- 52
9
votes
1 answer
MSBuild - Treat Warnings from editorconfig as Errors (enforce during build)
I set up an editorconfig file for my project and it works perfectly in my IDE and throws the right warnings. Examples: IDE0052 (unused variables) and IDE0055 (wrong formatting).
However, I would like to enforce the warnings from my editorconfig as…

ilovestackoverflow
- 117
- 1
- 5
9
votes
2 answers
Unused variable warning with static NSInteger, but not with NSString
After updating Xcode to version 5.1, I had a warning that told me I had defined a constant that I wasn't using. Its definition looked like this:
static NSInteger const ABCMyInteger = 3;
I was happy to see that it got marked, because I thought this…

Scott Berrevoets
- 16,921
- 6
- 59
- 80
8
votes
1 answer
Remove Unused Methods from xcode ios
I am using xcode 9 with objective c. And i want to remove unused variable and methods from classes. I am also use this way but xcode do not warning of unused methods etc. How to find out?

Shahbaz Akram
- 1,598
- 3
- 28
- 45
8
votes
3 answers
Property '...' is declared but never used
I have many unused params for my functions and constructors, usualy, an underscore does the trick
1) but here I still get the error message
I tried this (or adding an underscore)
/* tslint:disable-next-line:no-unused-variable */
constructor(private…

ninja
- 463
- 1
- 7
- 14
8
votes
2 answers
PHP: How do I best silence a warning about unused variables?
I have an application in which i have to declare (override) methods inherited from an interface. However, these methods have parameters that are not used in my implementation.
class MyImplementation implements ISomething {
public function…

Michal
- 1,955
- 5
- 33
- 56
8
votes
2 answers
Unused Local Variables (Visual Studio 2012)
I'm ridding my code of all compiler warnings, as per my bosses request, when I came across some unused local variables. Naturally, I removed the ones which were legitimate, however I stumbled upon a couple which aren't as straight forward. (Variable…

Steve Borland
- 360
- 3
- 12
8
votes
1 answer
Why is "unused variable" warning not reported for all variables?
I have this code:
// initializer lists
#include
#include
int main()
{
int values[] { 1, 2, 3 };
std::vector v { 4, 5, 6 };
std::vector cities {
"London", "New York", "Paris", "Tokio"
…

Jacob Krieg
- 2,834
- 15
- 68
- 140
8
votes
4 answers
Removing useless lines from c++ file
There are many times when as I am debugging, or reusing some code, the file starts to acquire lines that don't do anything, though they may have done something at one point.
Things like vectors and getting filled, and then go unused, classes/structs…

soandos
- 4,978
- 13
- 62
- 96
7
votes
1 answer
How to write a generic variadic lambda that discards its parameters?
I want to write a lambda that takes an arbitrary number of arguments by universal reference and ignores them entirely. The obvious method would be to use the syntax for a variadic universal parameter pack and omit the parameter name:
auto my_lambda…

ecatmur
- 152,476
- 27
- 293
- 366
7
votes
4 answers
Disable one unused variable warning
How can I disable one warning in one place only?
I have one variable which I temporarily don't use. Xcode shows me a warning about the "unused variable". I want to disable the warning, but for this variable only, not all warnings of this type.
Is it…

user2159978
- 2,629
- 2
- 16
- 14
6
votes
2 answers
Remove a property using object destructuring, without eslint no-unused-vars error
Consider the following code where I create a "copy" of x with one of the properties removed, using destructuring:
const x = { a: 1, b: 2, c: 3};
const { a, ...x2} = x;
console.log(x);
console.log(x2);
If I do it like this,…

Dániel Kis-Nagy
- 2,255
- 2
- 18
- 19
6
votes
3 answers
How to elegantly fix this unused variable warning?
I'm working on some C code that does lot's of error reporting and logging when a DEBUG flag is set, which sometimes produces unused variable warnings when compiling with the DEBUG flag not set.
#ifdef DEBUG
#define CHECK(expr)…

mort
- 12,988
- 14
- 52
- 97
6
votes
1 answer
Suppress unused variable warning
What is the best practice in Fortran to suppress warning messages like:
remark #7712: This variable has not been used.
for just one particular variable (imagine function in API that we do not want to break)?
Note: I do not want to suppress all…

Peter Petrik
- 9,701
- 5
- 41
- 65