Bug description:
When i tried to run the simple pattern cpp program i got an error in output that “unused variable” even though i have initialized the variable.
Expected vs Current Behavior:
I have written code with zero error
Hi @sudharshanm1916 , welcome to rhe forums!
‘Unused’ means that something (the variable) is there but you don’t use or call it.
So yes column is unused as you initialised it but never called it or used it anywhere. You can remove the line int column=5 and the program should work.
This program would normally work fine, but when compiling, you can see that the program uses the -Werror flag when compiling, so it treats all warnings as errors. To fix this, you can:
Edit the Makefile to remove -Werror
Remove the variable column completely (since you’re not using it anyways)
Add the attribute [[maybe_unused]]so the compiler knows that this variable may be unused, and it should compile.
Not my question, but trying to learn more. How does the sytax for the attribute work? Is it a part of the cpp file or is it part of the makefile magic?