"incompatible with C++98" warnings since Qt Creater update
-
I was prompted to upgrade my QT Creator installation yesterday. Since then I have started getting a load of warnings in C++ code about incompatibilities with C++98 (e.g.
'auto' type specifier is incompatible with C++98
). It doesn't seem to have caused any actual problems so far other than being a bit annoying.Anybody else seen this? Is it a bug that has been introduced or am I missing some new setting that I need to make somewhere?
My Qt Creator is now at 4.11.0.
-
@aha_1980 Thank you!
Based on information in linked threads I fixed it as follows:
- Go to Tools -> Options -> C++ -> Code Model
- Click Manage... on "Diagnostic configuration"
- Click Copy... to create a new configuration copied from "Checks for questionable constructs [built in]"
- Edit the copy to include " -Wno-c++98-compat" (i.e. should be "-Wall -Wextra -Wno-c++98-compat") and OK.
- Back in Tools -> Options -> C++ -> Code Model ensure the new configuration is set as the Diagnostic Configuration setting.
EDIT: I'm not sure why but when I tried to upvote @aha_1980 and mark the topic as being solved, the settings did not want to stick.
-
@Bob64 said in "incompatible with C++98" warnings since Qt Creater update:
@aha_1980 Thank you!
Based on information in linked threads I fixed it as follows:
- Go to Tools -> Options -> C++ -> Code Model
- Click Manage... on "Diagnostic configuration"
- Click Copy... to create a new configuration copied from "Checks for questionable constructs [built in]"
- Edit the copy to include " -Wno-c++98-compat" (i.e. should be "-Wall -Wextra -Wno-c++98-compat") and OK.
- Back in Tools -> Options -> C++ -> Code Model ensure the new configuration is set as the Diagnostic Configuration setting.
EDIT: I'm not sure why but when I tried to upvote @aha_1980 and mark the topic as being solved, the settings did not want to stick.
I just installed 5.14.0 on my laptop after reinstalling windows and was a few versions of Qt and creator behind. Now that I'm using 5.14.0 and Creator 4.11.0, when I opened the project I was last working on in the previous version that had no errors or warnings when compiled it was flooded with warnings like this.
This solution got rid of all of the warnings except 4. The latter 3 aren't strictly related through phrasing I believe they are still caused by extra compiler checks that were inadvertently turned on due to what was described in the thread that @aha_1980 linked.
- long long is incompatible with C++98
- declaration requires an exit-time destructor
- declaration requires a global destructor
- declaration requires a global constructor
I know these warnings are harmless and are just there to inform the user about potential portability (between C++ versions) and performance (the latter 3) issues but they were not present in the previous version of creator/Qt I was using (5.12.3, unsure about creator version). I did also upgrade to using MSVC2019, which may be the cause of these remaining warnings but I have no way of knowing for sure.
Hoping someone else has figured this out.
-
Although I can see instance where these warnings are more helpful, the cases where its triggered for me are quite trivial an sparse in most cases so I'd rather disable them. Thanks to the clang documentation at https://clang.llvm.org/docs/DiagnosticsReference.html, I was able to get rid of the latter three with
- -Wno-exit-time-destructors (declaration requires an exit-time destructor)
- -Wno-global-constructors (declaration requires a global destructor & declaration requires a global constructor)
As for the first one, while being easy to initially mistake with Wlong-long, you actually need to change this:
--Wno-c++98-compat
to
--Wno-c++98-compat-pedantic
All 4 of these extra warnings are now gone for me. The link to the clang documentation (that apparently is somewhat recent and originally was only available through a 3rd party community project on GitHub; seriously?) itself should be quite helpful to anyone who is having a similar issue.
-
Hi @oblivioncth ,
It worked for me too. Thanks.Regards,
Mucip:)