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. How to suppress warnings in qmake for clang++

How to suppress warnings in qmake for clang++

Scheduled Pinned Locked Moved General and Desktop
14 Posts 7 Posters 26.4k 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
    andre
    wrote on last edited by
    #5

    If possible at all: warnings should be fixed instead of ignored. Seriously. If you are not going to use a variable, be explicit about and either:

    remove the argument completely from the function, or

    remove the name of the argument from the function, or

    use a construct like Q_UNUSED(myVariable) to be explicit about you not using the argument.

    But don't just ignore the warning. Warnings are there for a reason. The may point to more severe issues or may develop into real problems later on.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bdemirkir
      wrote on last edited by
      #6

      Thanks for the info but I already know these rule of thumbs. I actually follow these rules. But this is not my project. This is a third party library and i'm not allowed to edit these library's source code. It's library writer's responsibility. I just want to suppress these warnings by editing pro file.

      In gcc @QMAKE_CXXFLAGS = -Wno-unused-variable@ should do the trick but in ==clang++== this method didn't work.

      Any suggestions?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #7

        [quote author="miroslav" date="1324471099"]@koahnig: The fact that Qt triggers a lot of warnings is actually quite annoying. From a code quality perspective, warnings have a urgency similar to errors, IMO. Often the only warnings that are impossible to get rid off are the ones generated by Qt itself.[/quote]

        Yes, I agree completely. The first time I was compiling Qt libs it was a shock to me when seeing the warnings. However, I (have) arranged myself with it.

        I am certainly agreeing also with Andre. He is summarizing my coding ethics.

        My answer was refering to the compilation of the Qt libs.

        On the other hand I find it more than a bit annoying that I have to clatter my code with pragmas for ignoring warnings when a Qt header is included. IMHO that is a nogo, but on an individual basis you are fighting against windmills there.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          miroslav
          wrote on last edited by
          #8

          Agreed. I do understand that it is hard to make sure no warnings are issued by any compiler. The issue could get a bit more focus, though.

          Mirko Boehm | mirko@kde.org | KDE e.V.
          FSFE Fellow
          Qt Certified Specialist

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bdemirkir
            wrote on last edited by
            #9

            Here's my console output for an unexpected warning generation:

            @clang++ -c -pipe -Wno-unused-variable -Wno-deprecated-writable-strings -O2 -arch x86_64 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.0/mkspecs/unsupported/macx-clang -I. -I/usr/local/Trolltech/Qt-4.8.0/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.8.0/include/QtCore -I/usr/local/Trolltech/Qt-4.8.0/include -I. -I. -F/usr/local/Trolltech/Qt-4.8.0/lib -o ltkcpp_genout.o ltkcpp_genout.cpp
            In file included from ltkcpp_genout.cpp:27:
            ./out_ltkcpp.inc:1312:3: warning: unused label 'missing' [-Wunused-label]
            missing:
            ^
            ./out_ltkcpp.inc:1321:33: warning: unused variable 'pType' [-Wunused-variable]
            const CTypeDescriptor * pType;
            ^@

            As you can see i passed ==-Wno-unused-variable== parameter but clang++ still generates unused-variable error.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #10

              Just poking in the dark. But I have noticed that there is a -Wall after -Wno-unused-variable.
              Could it be that you switching off the warning and switching it on with -Wall ?
              I do not know this compiler.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bdemirkir
                wrote on last edited by
                #11

                Oh! Yes that's what i'm missing. @koahnig Thank you very much. I should avoid using warn_on CONFIG directive.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tjrob
                  wrote on last edited by
                  #12

                  The problem with CONFIG += warn_off is that you don't get any warnings, but without it I get hundreds of useless warnings from a library. Adding -W flags to CPPFLAGS or QMAKE_CXXFLAGS doesn't help, because the warn_on generates a -Wall that comes after them.

                  SOLUTION: In the .pro file:
                  QMAKE_CXXFLAGS_WARN_ON = -Wall -Wno-unused-parameter

                  This sets the flags used when warn_on appears in CONFIG (the default). Now they are in the right order.

                  M 1 Reply Last reply
                  2
                  • D Offline
                    D Offline
                    digorydoo
                    wrote on last edited by
                    #13

                    +1 for this question. I have exactly the same problem. The reason why I want to get rid of these warnings is that I want to see no warnings except in the cases that are actually relevant. If I keep seeing irrelevant warnings, I will tend to ignore them and probably fail to see the relevant ones.

                    Unfortunately, I can't seem to get rid of them. The platform is win32, I tried each of these lines (separately, not all at one), to no avail:

                    @
                    QMAKE_CXXFLAGS += -wd4100
                    QMAKE_CXXFLAGS += -Wno-unused-parameter
                    QMAKE_CXXFLAGS += /wd4100 /wd4101 /wd4102 /wd4189 /wd4996
                    QMAKE_CXXFLAGS_WARN_ON = -Wall -Wno-unused-parameter
                    QMAKE_CXXFLAGS += -wd4100 -wd4101 -wd4102 -wd4189 -wd4996
                    @

                    With the last line above, the compile output looks like this:

                    @
                    cl -c -nologo -Zm200 -Zc:wchar_t -FS -wd4100 -wd4101 -wd4102 -wd4189 -wd4996 -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc /Fddebug\FirstQtTest.pdb -DUNICODE -DWIN32

                    more defines and includes follow here

                    @

                    There is no -Wall argument in my case, still it doesn't work. Any ideas?

                    1 Reply Last reply
                    0
                    • T tjrob

                      The problem with CONFIG += warn_off is that you don't get any warnings, but without it I get hundreds of useless warnings from a library. Adding -W flags to CPPFLAGS or QMAKE_CXXFLAGS doesn't help, because the warn_on generates a -Wall that comes after them.

                      SOLUTION: In the .pro file:
                      QMAKE_CXXFLAGS_WARN_ON = -Wall -Wno-unused-parameter

                      This sets the flags used when warn_on appears in CONFIG (the default). Now they are in the right order.

                      M Offline
                      M Offline
                      mabeghin
                      wrote on last edited by
                      #14

                      @tjrob said:

                      SOLUTION: In the .pro file:
                      QMAKE_CXXFLAGS_WARN_ON = -Wall -Wno-unused-parameter

                      This sets the flags used when warn_on appears in CONFIG (the default). Now they are in the right order.

                      This one worked for me ! Thanks a lot ! Removing particular warnings that are generated by external libraries is very useful to still be able to see important ones. When possible I prefer to add specific pragmas when including headers but it's not always possible

                      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