Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debugging error "Werror=unused-but-set-variable"

Tags:

c

gcc

debugging

I got an error in file xyz.c error: in function 'xyzz' variable 'i' set but not used [-Werror=unused-but-set-variable] and in that particular line and column, I found (void *) what is the error, can someone please help?

like image 708
Rohit Kapoor Avatar asked Jan 16 '23 21:01

Rohit Kapoor


1 Answers

You seem to have assigned a value to your variable i, but not used it afterwards. This would normally not generate an error, but rather a warning (depending on how you have your warning flags set), since the compiler assumes that you wanted to do something with this variable, but forgot about it.

The setting for having this as a warning is -Wunused-but-set-variable

However, you seem to have set this as generating an error: -Werror=unused-but-set-variable

Having (certain or all) warnings as errors can be useful in order to test your code more rigidly. Are you sure you want this here?

See http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html for more options.

like image 136
Michael Brandl Avatar answered Jan 28 '23 15:01

Michael Brandl