Warnings: Feast or Famine
-
Howdy,
As of a few Qt or Qt Creator updates ago, I've been having issues with compiler errors and warnings. I've perused the forums and stack overflow, and, while many others seem to be having various similar symptoms, the fixes offered to them don't seem to apply to my case.
The current 'famine' problem is that there are almost no build issues reported in the Issues pane. I see 12 there, but if I run the analyzer, I have to kill it when it exceeds 64 k, as it shows no sign of ever finishing. Examining the Compile Output, the same seems to be true - basically no 'red' warnings (or warnings at all).
I'm building on macOS, using clang and qmake (not cmake). I've tried inserting QMAKE_CXXFLAGS += -Wall everywhere I can think of - various .pro files, Projects>Build Environment, the mkspecs .conf file for clang - with no apparent effect. (I note that I can grep the whole project, and the string 'QMAKE_CXXFLAGS' doesn't exist, except in the .pri files of one third-party library.)
The 'feast' problem referred to in my subject line is the previous behavior. Before they all went away and hid, I used to get the tens of thousands of warnings the analyzer shows me in the Issues tab, and I still see them in the individual source files. There was no method I could find to hide specific warnings (e.g. the old style cast or signed/unsigned mismatch warnings that make up the bulk of the firehose spray). This was annoying, but functional. Not seeing warnings except while traversing the hundreds of source files in this project is unusable.
Help?
-
@kenchan - Thanks for replying. I kind of feel like I'm in freefall now, having looked in more detail into those .conf files. I can't begin to parse them or how they work. (E.g. I see both the QMAKE_CXXFLAGS_WARN_ON and _OFF are defined in the base .conf, but have no idea how/where they are invoked.)
Further, I discovered the reason that there were no warnings coming from one of the major libraries: someone had put 'CONFIG+=warn_off' into its .pro file. Do you know where warn_off is 'declared/defined'? It seems to the 'user' switch for the _WARN_ON/_OFF flags you recommended.
Of course, while removing warn_off creates tons of warnings, putting 'QMAKE_CXXFLAGS += -Wno-missing-braces' (thousands of these is a autogenerated header file) in its place seems to have no effect. I really don't understand what I'm doing, or how I'm supposed to know what I'm doing - this seems like an entire parallel set of complex build instructions that can only be navigated file by file.
I've never had so much trouble with an IDE before; are these things I'm trying to do (turn on/off specific warnings) supposed to be so difficult?
-
@aha_1980 - I'm not sure why deactivating the analyzer's editor output would activate the compiler's compile output, but I suppose it can't hurt to try.
To be clear, the main issue is that I see very few warnings in the Compile Output and Issues when I clean all, run qmake, and rebuild everything. It seems like the compiler is running in some minimal error/warning mode, while the analyzer is running in a maximal error/warning mode. I don't really want to shut off the analyzer and pretend like everything's fine.
-
@aha_1980 - Also, there is no Help>About Plugins on the Mac. I believe the comparable menu is Qt Creator>About Plugins. It's very frustrating that the Qt documentation all seems to presuppose that everyone's running on Windows; this one's pretty minor, but some differences are significant.
And no, it doesn't help to use the built-in code model. As far as I can tell, it makes no difference?
-
More data, after another day of research & experimentation:
-
Nothing I do seems to affect the warnings produced in the Compile Output (and thus Issues) panes when I clean all, run qmake, and run.
-
Modifying the 'Diagnostic Configuration' (Custom Settings on the Analyzer Configuration, reached from Analyze>Clang Tidy and Clazy...) and files to be analyzed removes/add warnings as expected when running the analyzer, but has no effect on the inline warnings in the source editor.
-
Turning off the ClangCodeModel (Qt Creator>About Plugins...) kills off the inline warnings in the source editor, but has no other obvious effects.
This seems to me like insanity: there appear to be three completely independent ways to generate error/warning analysis, only one of which is configurable (the analyzer). And on a practical level, I'm left needing to run the analyzer in order to have any confidence that I've actually handled all the relevant issues in my project.
PS - The first hit in Google on searching 'Weverything' is a page about how this is a terrible switch to use on a regular basis. It's the default setting for the analyzer.
-
-
Hi @wumpus7,
Nothing I do seems to affect the warnings produced in the Compile Output (and thus Issues) panes when I clean all, run qmake, and run.
QMAKE_CXXFLAGS
is already the right (and only) way. You need to check the compile output, if the flags are really passed to the compiler - because the compiler generates the warnings.Turning off the ClangCodeModel (Qt Creator>About Plugins...) kills off the inline warnings in the source editor, but has no other obvious effects.
And that's exactly what I wrote in my post yesterday. If you want to keep the inline annotations, you have to enable Clang again and then modify the settings in Tools > Options > C++ > Code Model > Clang Code Model.
Modifying the 'Diagnostic Configuration' (Custom Settings on the Analyzer Configuration, reached from Analyze>Clang Tidy and Clazy...) and files to be analyzed removes/add warnings as expected when running the analyzer, but has no effect on the inline warnings in the source editor.
And that's expected, as it only influences the static analyzer you can call by Analyze > Clang Tidy and Clazy...
So, to keep it short:
- Compiler warnings are configured with
QMAKE_CXXFLAGS
- Inline annotations are configured with Tools > Options > C++ > Code Model > Clang Code Model
Does that help you?
Edit:
'Weverything' is a page about how this is a terrible switch to use on a regular basis. It's the default setting for the analyzer.
- You can always change that
- The analyzer is thought to bring up any issue you code may have, much more pedandic than a compiler does. That's the whole point of an analyzer.
- Compiler warnings are configured with
-
@aha_1980 said in Warnings: Feast or Famine:
Hi @wumpus7,
Nothing I do seems to affect the warnings produced in the Compile Output (and thus Issues) panes when I clean all, run qmake, and run.
QMAKE_CXXFLAGS
is already the right (and only) way. You need to check the compile output, if the flags are really passed to the compiler - because the compiler generates the warnings.As I said in my initial post, I have attempted to modify the QMAKE_CXXFLAGS everywhere possible in the project - none of them affect the output of the compiler in the Compile Output pane. None. Where precisely am I meant to put this? Is this just broken on the Mac and no one else uses the Mac?
Turning off the ClangCodeModel (Qt Creator>About Plugins...) kills off the inline warnings in the source editor, but has no other obvious effects.
And that's exactly what I wrote in my post yesterday. If you want to keep the inline annotations, you have to enable Clang again and then modify the settings in Tools > Options > C++ > Code Model > Clang Code Model.
Yes, I have seen you say this here and in other posts. It doesn't work on my system, as I've said several times now. There is no Tools > Options > C++ > Code Model > Clang Code Model menu in the Mac's Qt Creator! The presumed equivalent that I found (below) only affects the analyzer. Searching again, I see a Tools>C++ with only one selectable option 'Inspect C++ Code Model'. Is that the Mac equivalent (is C++ == Clang)? I'll try messing with it and see...
Modifying the 'Diagnostic Configuration' (Custom Settings on the Analyzer Configuration, reached from Analyze>Clang Tidy and Clazy...) and files to be analyzed removes/add warnings as expected when running the analyzer, but has no effect on the inline warnings in the source editor.
And that's expected, as it only influences the static analyzer you can call by Analyze > Clang Tidy and Clazy...
I'd never even have tried the analyzer if I weren't unable to get anything else to work reasonably. As things stand, it's the only functional resource I've discovered.
So, to keep it short:
- Compiler warnings are configured with
QMAKE_CXXFLAGS
- Inline annotations are configured with Tools > Options > C++ > Code Model > Clang Code Model
Does that help you?
No, but perhaps answers to my reply will?
Thanks for trying, I do appreciate it.
Edit:
'Weverything' is a page about how this is a terrible switch to use on a regular basis. It's the default setting for the analyzer.
- You can always change that
Using a very poorly documented (for the Mac, at least) process, sure.
- The analyzer is thought to bring up any issue you code may have, much more pedandic than a compiler does. That's the whole point of an analyzer.
Unless the point of the analyzer is to debug the compiler, Weverything is still not appropriate, from what I've read.
- Compiler warnings are configured with
-
@wumpus7 said in Warnings: Feast or Famine:
Searching again, I see a Tools>C++ with only one selectable option 'Inspect C++ Code Model'. Is that the Mac equivalent (is C++ == Clang)? I'll try messing with it and see...
I'm pretty sure 'Inspect C++ Code Model' can only inspect and not modify, but I could easily be wrong. I certainly see no obvious way to use it to change compiler flags.
-
For those keeping score at home, I've solved all my issues except the one that brought me here, which is that I can't seem to get the actual compile to accept flags. I've tried putting 'QMAKE_CXXFLAGS += -Wall' everywhere I can, and it doesn't seem to affect the compile output.
If anyone has successfully made such a modification to their project on a Mac, please let me know where exactly you put the CXXFLAGS annotation (Specific menu, screen, file, whatever.)
-
@kenchan said in Warnings: Feast or Famine:
There are also these two
QMAKE_CXXFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_OFFThe question isn't which flags, it's where to put them. Have you successfully applied these flags to a (Mac) project? If so, how?
-
More experimentation, more data:
The project I'm working on has numerous .pro files, as it consists of a main app which depends on several in-house and third-party libraries. So I have a choice of where to try putting QMAKE_CXXFLAGS lines.
Firstly, though, here is a typical build call from the current Compile Output:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.12 -Wall -W -fPIC -Dappstore -DQT_QML_DEBUG -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../qtmasterfader/MasterFaderCore -I. -I/Users/abroad/Documents/qtmasterfader/SubmoduleIncludes/../QtZeroConf_debug -I../../qtmasterfader/MasterFaderCore/easyexif -I../../../Qt5.12/5.12.1/clang_64/lib/QtNetwork.framework/Headers -I../../../Qt5.12/5.12.1/clang_64/lib/QtGui.framework/Headers -I../../../Qt5.12/5.12.1/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/Applications/Xcode10.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/Applications/Xcode10.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/AGL.framework/Headers/ -I../../../Qt5.12/5.12.1/clang_64/mkspecs/macx-clang -F/Users/abroad/Qt5.12/5.12.1/clang_64/lib -o device.o ../../qtmasterfader/MasterFaderCore/device.cpp
Note that -Wall and -W (which is the same as -Wextra) are already set! However, they do not appear to be working, as constructions flagged by -Wall in the analyzer aren't showing up in the Compile Output. This is now the heart of the mystery.
If I add, e.g. -Wold-style-cast to:
- the main project .pro file, nothing happens. The flag doesn't show up in the compile output at all.
- the app project .pro file (where 'main.cpp' resides), the flag shows up in the compile output for all the source files in that part of the project, and they generate old style cast related warnings.
- particular libraries' .pro files, the flag shows up in the compile output for the source files for that particular library, and they generate warnings.
So there doesn't appear to be a way to apply flags to the entire build at once, but I was wrong, in that I do appear to be able to set flags via QMAKE_CXXFLAGS in .pro files. It's just that -Wall is apparently 1) already set via some other mechanism, and 2) not working.
Does anyone know why -Wall -W doesn't seem to generate any warnings in the compiler, but does in the editor or analyzer?
-
@wumpus7
Yes i use it on a mac in my single pro file.If you look in the file called gcc-base.conf in the <path to your Qt install>clang_64/mkspecs/common folder you can see how all the flags are used.
Take a look at the qmake.conf file under the mkspecs/macx-clang folder to see what is used when building on a mac. -
@kenchan - Thanks for replying. I kind of feel like I'm in freefall now, having looked in more detail into those .conf files. I can't begin to parse them or how they work. (E.g. I see both the QMAKE_CXXFLAGS_WARN_ON and _OFF are defined in the base .conf, but have no idea how/where they are invoked.)
Further, I discovered the reason that there were no warnings coming from one of the major libraries: someone had put 'CONFIG+=warn_off' into its .pro file. Do you know where warn_off is 'declared/defined'? It seems to the 'user' switch for the _WARN_ON/_OFF flags you recommended.
Of course, while removing warn_off creates tons of warnings, putting 'QMAKE_CXXFLAGS += -Wno-missing-braces' (thousands of these is a autogenerated header file) in its place seems to have no effect. I really don't understand what I'm doing, or how I'm supposed to know what I'm doing - this seems like an entire parallel set of complex build instructions that can only be navigated file by file.
I've never had so much trouble with an IDE before; are these things I'm trying to do (turn on/off specific warnings) supposed to be so difficult?
-
@wumpus7
I am sure you have looked at the Qmake documentaton but if you here you can see where the "warn_off"
flag is predefined for CONFIG.
Beyond that I cannot claim to be a qmake guru so am afraid I am also getting out of my depth.
BTW, I could not find a -Wno-missing-braces item in the clang documentation maybe that is the problem. -
@kenchan - Again, thanks. I've successfully used -Wno-missing-braces on the analyzer and editor, so it 'works' for at least some versions of the compiler.
As for 'warn_on'/'warn_off', I had no trouble verifying their existence/function once I found them in the .pro file, but I had no prior warning to look for such a thing. I've been looking for QMAKE_CXXFLAGS, not weird macros that are defined in some middle ground between the .conf files and the .pro files. I don't understand how the .conf files work, much less how to successfully invoke half of the options documented there and elsewhere.
On the other hand, I think that I've solved my main issue with the discovery of the hidden 'warn_off' in my library's .pro file. I have compile warnings again. More than I'd like, true, and I don't seem to be able to turn off specific warnings, but fixing the autogenerated code should get rid of the majority of the offending bits, so I can at least have some confidence in my builds again.