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 "mute" specific warnings?
Forum Updated to NodeBB v4.3 + New Features

How to "mute" specific warnings?

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 1.4k Views 3 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.
  • EngelardE Offline
    EngelardE Offline
    Engelard
    wrote on last edited by Engelard
    #1

    Teach me please how to mute warnings which does nothing but annoying the user.

    For example, i have perfectly working C++17 initialization in "IF" statement, but it gives me warnings everywhere anyway:

    warning: 'if' initialization statements are a C++17 extension
    
    Pablo J. RoginaP 1 Reply Last reply
    0
    • EngelardE Engelard

      Teach me please how to mute warnings which does nothing but annoying the user.

      For example, i have perfectly working C++17 initialization in "IF" statement, but it gives me warnings everywhere anyway:

      warning: 'if' initialization statements are a C++17 extension
      
      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @Engelard said in How to "mute" specific warnings?:

      how to mute warnings which does nothing but annoying the user

      Ideally, you should understand the reason(s) and remove the conditions leading to such warnings, not turn warnings off.

      Wouldn't you think that the developers of the compiler(s) have a very good reason to let you know about them?

      In any case, they have thought beforehand "this case is worth mentioning, so it can be considered", and in addition, you're getting some insights and advice for free...

      If not, you're killing the messenger...

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      EngelardE 1 Reply Last reply
      2
      • Pablo J. RoginaP Pablo J. Rogina

        @Engelard said in How to "mute" specific warnings?:

        how to mute warnings which does nothing but annoying the user

        Ideally, you should understand the reason(s) and remove the conditions leading to such warnings, not turn warnings off.

        Wouldn't you think that the developers of the compiler(s) have a very good reason to let you know about them?

        In any case, they have thought beforehand "this case is worth mentioning, so it can be considered", and in addition, you're getting some insights and advice for free...

        If not, you're killing the messenger...

        EngelardE Offline
        EngelardE Offline
        Engelard
        wrote on last edited by Engelard
        #3

        @Pablo-J-Rogina said in How to "mute" specific warnings?:

        Wouldn't you think that the developers of the compiler(s) have a very good reason to let you know about them?

        Such a warning gives no usefull information. Yes i know that it is C++17 stuff, so what, that's why i added it to the .pro file so it could be working, but after i made it working warning is still here, which again - tells the user nothing. Then it is badly made warning if it does'nt warn about anything, right?

        Pablo J. RoginaP 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          What compiler are you using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • EngelardE Engelard

            @Pablo-J-Rogina said in How to "mute" specific warnings?:

            Wouldn't you think that the developers of the compiler(s) have a very good reason to let you know about them?

            Such a warning gives no usefull information. Yes i know that it is C++17 stuff, so what, that's why i added it to the .pro file so it could be working, but after i made it working warning is still here, which again - tells the user nothing. Then it is badly made warning if it does'nt warn about anything, right?

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @Engelard said in How to "mute" specific warnings?:

            i know that it is C++17 stuff, so what, that's why i added it to the .pro

            it's just more than updating the .pro file. That's only the first step.

            but after i made it working warning is still here
            and as you have experienced,

            It looks like you made not it working. You need to change your code, by understanding what the warning is telling you; why the compiler (and the compiler developers) is making you aware of that no so good condition in your code that they consider worth rising a warning

            Have you just searched for just at least one of your warnings, to see what possible solutions are proposed to avoid it?

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            EngelardE 1 Reply Last reply
            1
            • Pablo J. RoginaP Pablo J. Rogina

              @Engelard said in How to "mute" specific warnings?:

              i know that it is C++17 stuff, so what, that's why i added it to the .pro

              it's just more than updating the .pro file. That's only the first step.

              but after i made it working warning is still here
              and as you have experienced,

              It looks like you made not it working. You need to change your code, by understanding what the warning is telling you; why the compiler (and the compiler developers) is making you aware of that no so good condition in your code that they consider worth rising a warning

              Have you just searched for just at least one of your warnings, to see what possible solutions are proposed to avoid it?

              EngelardE Offline
              EngelardE Offline
              Engelard
              wrote on last edited by
              #6

              @Pablo-J-Rogina said in How to "mute" specific warnings?:

              Have you just searched for just at least one of your warnings

              Yes, yesterday it took whole evening, with no result, since the furthest answer i digged-up is what i already have(and i say it again - it compiles and working):

              CONFIG += c++17
              QMAKE_CXXFLAGS += -std:c++1z
              

              @Pablo-J-Rogina said in How to "mute" specific warnings?:

              by understanding what the warning is telling you

              As i understand, there is no single example, when C++17 is working, but warning is left/ Every link is about to make ++17 work.

              @Pablo-J-Rogina said in How to "mute" specific warnings?:

              You need to change your code, by understanding what the warning is telling you

              Everything is written well, it works, idk what could be wrong, no single hint from Qt:
              alt text

              @SGaist said in How to "mute" specific warnings?:

              What compiler are you using ?

              alt text

              JonBJ 1 Reply Last reply
              0
              • EngelardE Engelard

                @Pablo-J-Rogina said in How to "mute" specific warnings?:

                Have you just searched for just at least one of your warnings

                Yes, yesterday it took whole evening, with no result, since the furthest answer i digged-up is what i already have(and i say it again - it compiles and working):

                CONFIG += c++17
                QMAKE_CXXFLAGS += -std:c++1z
                

                @Pablo-J-Rogina said in How to "mute" specific warnings?:

                by understanding what the warning is telling you

                As i understand, there is no single example, when C++17 is working, but warning is left/ Every link is about to make ++17 work.

                @Pablo-J-Rogina said in How to "mute" specific warnings?:

                You need to change your code, by understanding what the warning is telling you

                Everything is written well, it works, idk what could be wrong, no single hint from Qt:
                alt text

                @SGaist said in How to "mute" specific warnings?:

                What compiler are you using ?

                alt text

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @Engelard
                I do understand that you do not have anything wrong in your code given that you are compiling for C++ 17, and simply do not want it to warn you that this is a C++ 17 feature.

                What you did not indicate at all, till your screenshot, is that this is a warning you see in Qt Creator IDE. Does this warning not occur when you actually compile? Please tell us this.

                In which case, if it's Creator only, I am no expert but I know Creator uses Clang under Linux to do its parsing/warnings. I do not know what the situation is under Windows, and using MSVC. Under Linux/gcc, I can go to Help > About Plugins and disable Clang Code Model. (Or there is Tools > Options > C++ > Code Model and you can manage Clang from there, I haven't done that.) If you can do that, and disable Clang, does the warning disappear from Creator?

                EngelardE 1 Reply Last reply
                0
                • JonBJ JonB

                  @Engelard
                  I do understand that you do not have anything wrong in your code given that you are compiling for C++ 17, and simply do not want it to warn you that this is a C++ 17 feature.

                  What you did not indicate at all, till your screenshot, is that this is a warning you see in Qt Creator IDE. Does this warning not occur when you actually compile? Please tell us this.

                  In which case, if it's Creator only, I am no expert but I know Creator uses Clang under Linux to do its parsing/warnings. I do not know what the situation is under Windows, and using MSVC. Under Linux/gcc, I can go to Help > About Plugins and disable Clang Code Model. (Or there is Tools > Options > C++ > Code Model and you can manage Clang from there, I haven't done that.) If you can do that, and disable Clang, does the warning disappear from Creator?

                  EngelardE Offline
                  EngelardE Offline
                  Engelard
                  wrote on last edited by Engelard
                  #8

                  @JonB said in How to "mute" specific warnings?:

                  Does this warning not occur when you actually compile?

                  After compile it still shown. Ah, forgot to mention bunch of those same D9002 which appeared as well(after i used in IF declaration):
                  alt text

                  @JonB said in How to "mute" specific warnings?:

                  (Or there is Tools > Options > C++ > Code Model and you can manage Clang from there

                  Tnx, i know that, was used long time ago, and i was tell proper warning codes:
                  alt text

                  And i suppose this is the point of this topic, that i forgot to mention - i need to know how get clang codes by myself, like "Wno-unused-parameter" - where would i get that?

                  1 Reply Last reply
                  0
                  • EngelardE Offline
                    EngelardE Offline
                    Engelard
                    wrote on last edited by
                    #9

                    Ow, i recalled, here it is:
                    alt text

                    Added that to my Clang(see screenshot above), -Wc++17-extensions but warning still here... Even after i reloaded qt.

                    JonBJ 1 Reply Last reply
                    0
                    • EngelardE Engelard

                      Ow, i recalled, here it is:
                      alt text

                      Added that to my Clang(see screenshot above), -Wc++17-extensions but warning still here... Even after i reloaded qt.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #10

                      @Engelard
                      Please look at your "unknown option" warnings, you didn't tell us.

                      QMAKE_CXXFLAGS += -std:c++1z
                      

                      I guess that needs sorting out. Maybe you are still not correctly C++17 somewhere.

                      EngelardE 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Engelard
                        Please look at your "unknown option" warnings, you didn't tell us.

                        QMAKE_CXXFLAGS += -std:c++1z
                        

                        I guess that needs sorting out. Maybe you are still not correctly C++17 somewhere.

                        EngelardE Offline
                        EngelardE Offline
                        Engelard
                        wrote on last edited by
                        #11

                        @JonB said in How to "mute" specific warnings?:

                        Maybe you are still not correctly C++17 somewhere.

                        :D
                        How could i check such a things? And it is C++17, since everything working as it should, and i would even dive in to that many-days-resolving thing for such a warnings, but unfortunately i don't have time for that. That's why topic named "How to "mute" specific warnings?"

                        JonBJ 1 Reply Last reply
                        0
                        • EngelardE Engelard

                          @JonB said in How to "mute" specific warnings?:

                          Maybe you are still not correctly C++17 somewhere.

                          :D
                          How could i check such a things? And it is C++17, since everything working as it should, and i would even dive in to that many-days-resolving thing for such a warnings, but unfortunately i don't have time for that. That's why topic named "How to "mute" specific warnings?"

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #12

                          @Engelard
                          No, I think you want to resolve this one. Do you not think it might be the root of your problem?

                          You have:

                          -std:c++1z
                          

                          Since it states "unknown option" did you examine it? Where did you get that from? Are you sure it is not supposed to be:

                          -std=c++1z
                          

                          ?

                          EngelardE 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @Engelard
                            No, I think you want to resolve this one. Do you not think it might be the root of your problem?

                            You have:

                            -std:c++1z
                            

                            Since it states "unknown option" did you examine it? Where did you get that from? Are you sure it is not supposed to be:

                            -std=c++1z
                            

                            ?

                            EngelardE Offline
                            EngelardE Offline
                            Engelard
                            wrote on last edited by Engelard
                            #13

                            @JonB said in How to "mute" specific warnings?:

                            Are you sure it is not supposed to be:
                            -std=c++1z

                            Tried. All remains the same:
                            alt text

                            UPD:

                            That array of "unknowing options" was because i was experimenting with parameters, when i set back to :

                            CONFIG += c++17
                            QMAKE_CXXFLAGS += -std:c++17
                            

                            those are gone, but "'if' initialization" is still present.

                            UPD2:

                            I looked at my old warnings in the clang, and noticed that for removing warnings, must be not '-W' but '-Wno-'. So now that senseless warning is gone, tnx everyone in this topic for helping resolving that warning.

                            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