Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt Creator misdetect unused vaiables.
Somtimes it's can detect sometimes it's can't. What?
Even on current opened source file, I try to declare 10 unused variables on it and it's say nothing after builded. OMG
Qt 5.3.0 for Windows 32-bit (MinGW 4.8.2, OpenGL, 734 MB)
Windows 8.1 64-bits
You talk about build warnings, which are (or, in your case, are not) raised by the compiler you are using, and not by Qt Creator.
Could you provide a bit more info, like when exactly is it failing, and show us the offending code?
But how could compiler misdetect such a simple unused variable.
I just create new project on Qt Creator by select "Qt widgets application",
add new header and source file, write some code then build and it work fine except sometimes it's misdetect on unused varibles. On editor it's show the green underline but the compiler say nothing. ;)
It's just a simple string
Unless you are explicitly suppressing the warnings (maybe in project settings, or in the .pro file), they should be shown. I definitely get those warnings when compiling (Linux clang, Linux g++, Windows MSVC).
You can check with "compile output" in Qt Creator: all compiler call should have "-Wall" in them. You can add "-Wunused-variable" yourself, too.
@g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN@
It' has. Hmm...
Should I use MSVC instead mingw?
mingw should work fine, I am surprised you are getting this issue.
You can try switching to MSVC if you have the possibility, but for such a small problem I doubt it is worth the effort.
Please try following the hint from here to add -Wunused-variable: "link":http://stackoverflow.com/questions/1881698/changing-the-warning-level-with-qt-creator-and-mingw.
Ah, one more thing. You say it sometimes works, and sometimes does not. Please remember that the build system will not build files that have not changed since last build (this is detected automatically to shorten compilation time). To really see all the warnings, you need to fully rebuild your project (that is, either run "Clean" then "Build" or use the "Rebuild" option from Qt Creator).
Oh. I see it's warning just once if it's not changed. Fool me ;)
Happens to everybody :D You can see it took me 3 hours to actually think of the simplest explanation ;-)