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?
-
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 warningHave 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:
@SGaist said in How to "mute" specific warnings?:
What compiler are you using ?
-
@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):
@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:
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?
-
@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++1zTried. All remains the same:
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.