Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to "mute" specific warnings?



  • 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
    


  • @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...



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


  • Lifetime Qt Champion

    Hi,

    What compiler are you using ?



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



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



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



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



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



  • @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.



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



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

    ?



  • @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.


Log in to reply