Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Creator misdetect unused vaiables.

Qt Creator misdetect unused vaiables.

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 4.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arrandale
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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?

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Arrandale
        wrote on last edited by
        #3

        Hmm... OK.
        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
        @QString text1;
        QString text2;
        QString text3;
        QString text4;@

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          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.

          (Z(:^

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Arrandale
            wrote on last edited by
            #5

            @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?

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              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).

              (Z(:^

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Arrandale
                wrote on last edited by
                #7

                Oh. I see it's warning just once if it's not changed. Fool me ;)

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  Happens to everybody :D You can see it took me 3 hours to actually think of the simplest explanation ;-)

                  Happy coding!

                  (Z(:^

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Arrandale
                    wrote on last edited by
                    #9

                    lol Thanks.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved