Questions tagged [unused-variables]

Use this tag when question related to unused variables issues as warnings

179 questions
2
votes
1 answer

(void)variable alternative for Rust

As the title says is there an alternative for (void)variable like C/C++ in Rust. I have a callback function which look something like: fn on_window_event(window: &cgl_rs::Window, event: &cgl_rs::Event) -> bool { // ... some code ... …
Jaysmito Mukherjee
  • 1,467
  • 2
  • 10
  • 29
2
votes
1 answer

Unused let expression in Ocaml

Why can't I compile a program with unused variables in Ocaml? let foo a b = a + b -- Error (warning 32 [unused-value-declaration]): unused value foo.
2
votes
0 answers

How to gray out unused C++ variables in VSCode?

VSCode grays out unused variables/imports in JS and TS files. I use VSCode for writing C++ code also and I have the C/C++ extension installed too. I want VSCode to also gray out unused C++ variables in my code and maybe also show a warning (if…
2
votes
2 answers

How to fix "error:expected primary-expression before ‘,’ token"

I am trying to make a first fit memory management code but everytime I try to run it I keep getting incomplete results in the output and these errors error:expected primary-expression before ‘,’ token I don't know what to put in the code to resolve…
2
votes
0 answers

How to suppress warnings from a go module?

I'm using gosseract, a Go OCR package that uses Tesseract for reading characters from images. I am using the demo's code right now like so: client := gosseract.NewClient() defer client.Close() client.SetImage("helloworld.png") text, _ :=…
2
votes
1 answer

Suppressing Warning in Rescript: Js.Promise.make

When making a promise in Rescript: let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2)) The ReScript compiler will give a warning on unused variable reject. Is there a way to suppress this error?
heiheihang
  • 82
  • 9
2
votes
1 answer

getting unused variable warnings even though I am using the variables

In the following code, I get a token I am querying multiple databases which return Future. I want to do the next query based on the outcome of the previous one. val result:Future[Result] = for{tokenOption:Option[UserToken] <- if(urlHost != "" &&…
Manu Chadha
  • 15,555
  • 19
  • 91
  • 184
2
votes
1 answer

Ignore unused variables in a block of code in c

I have a large codebase of C code which part of it is generated code from the Oracle Pro*C precompiler. We use the GNU gcc compiler. The Pro*C precompiler generates code that contains unused variables that emits many warnings related to…
SimonW
  • 6,175
  • 4
  • 33
  • 39
2
votes
2 answers

Why "unused attribute" generated warning for array of struct?

Here used, unused attribute with structure. According to GCC document: unused : This attribute, attached to a variable, means that the variable is meant to be possibly unused. GCC will not produce a warning for this variable. But, In the…
msc
  • 33,420
  • 29
  • 119
  • 214
2
votes
2 answers

Excluding type evidence parameters from analysis in Scala when using -Ywarn-unused

Compiling a program that contains a type evidence parameter in Scala (such as T <:< U) can cause a warning when -Ywarn-unused is passed to the compiler. Especially in the case when the type evidence parameter is used to verify a constraint encoded…
2
votes
1 answer

Use of variable in 'for' loop is not recognized in Go

I'm developing in Go and I run the following for loop: // Define Initial Value i := 0 for { // Get random data based on iteration data, i := GiveRandomData(i) // Save to database response, err := SaveToDatabase(data) if err !=…
2
votes
1 answer

Suppressing unused warnings for the entire class with eclipse

I am working on a page-object class using Selenium and Eclipse (though this question applies to Eclipse in general). I am defining some strings, sometimes based on other strings. As in the example below which is a simple example: private static…
Tony
  • 367
  • 1
  • 7
  • 17
2
votes
1 answer

unused-variable warning different for auto variables

Using gcc (4.7.2 here) I get warnings about unused auto variables, but not about other variables: // cvars.h #ifndef CVARS_H_ #define CVARS_H_ const auto const_auto = "const_auto"; const char const_char_array[] = "const_char_array"; const char *…
ricab
  • 2,697
  • 4
  • 23
  • 28
2
votes
4 answers

How to find irrelevant unused attributes?

While reading parts of the code of a big C project, I found some arguments that were marked as unused but were in fact used in the function. I thought about grepping the unused attributes but there are too many of them to manually verify if they are…
Maxime Chéramy
  • 17,761
  • 8
  • 54
  • 75
2
votes
4 answers

How to enforce parameters of anonymous blocks to be unused in Objective-C?

I've run into a situation while using a library called TransitionKit (helps you write state machines) where I am want to supply entry and exit actions in the form of a callback. Sadly, the callbacks include two completely useless parameters. A…
fatuhoku
  • 4,815
  • 3
  • 30
  • 70