Solved Yet another post to Qt creator 4.7.0
-
After updating to most recent Qt creator 4.7.0 I receive buckets of warnings throughout my source.
Also lines like
qDebug() << "my special output";
are marked by a warning that "zero as null pointer constant".
Naivly I assumed that I have adopted some less favorable over the years. Right now I checked the documentation and found qDebug() is used correctly. The warning stems apparently from using an older Qt version 5.4.
Does anyone know how to get rid of those warnings for older Qt lib versions?
-
Hi @koahnig,
Right now you can adopt the Clang warnings globally or per project.
Setting them per Kit is not possible AFAIK. But as I have a lot of legacy code I stumbled over the same problem some days ago.
If two have it, it's worth a bugreport I think. Do you want to create one?
-
@aha_1980 said in Yet another post to Qt creator 4.7.0:
Hi @koahnig,
Right now you can adopt the Clang warnings globally or per project.
You mean with that switching off warnings with macros and/or compile switches?
I can write a bug report and post link here.
-
No, you can disable the warning from Clang. Tools > Options > C++ > Code Model > Manage. Then create a copy and modify the warning options to your need (I think you need to add -Wno-zero-as-null-pointer-constant)
It would be good to assign that at Kit level, IMHO.
Regards
-
Bug report filed https://bugreports.qt.io/browse/QTCREATORBUG-20877
-
qDebug is a macro, but I can't see how it can resolve to anything that warrants a "zero as null pointer constant" warning...
Do you set any special DEFINE's , like QT_NO_DEBUG_OUTPUT? Have you tried isolating it to a minimal example?
-
Thanks for feedback.
I didn't before, but tried right now.
I cannot provide a minimal example.With my large legacy project the warning disappears as soon as I choose the kit with Qt 5.10. After selecting the another than this kit Qt 5.4.2 (MinGW pre-build) or self-compiled Qt5.9.3 (also MinGW) the warning appears in editor.
For the minimla example I have used the standard template from qt creator and included QDebug and wrote
qDebug() << "test output";
There must be something else then.[edit:koahnig]
-
Sorry that was stupid. Ignore previous post. I blame it to the heat and the up-coming weekend. ;)
I had changed the settings in creator to ignore the warning.Here it is with prebuild Qt5.4.2 MinGW on windows 10 64 bit
main.cpp
#include <QCoreApplication> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); qDebug() << "test output"; return a.exec(); }
QT -= gui CONFIG += c++11 console CONFIG -= app_bundle # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
-
I see. I guess you've selected a Release build? Then I can reproduce.
qDebug is actually a macro in Qt 5, so that additional metadata can be captured:
#define qDebug QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).debug
QMessageLogger expects strings (const char *) as first and third constructor argument. However, for release builds QT_MESSAGELOG_FILE, QT_MESSAGELOG_FUNC were defined to 0.
This got changed in Qt 5.5.0 so that they are defined to nullptr. This is why you cannot reproduce in dev ...
I don't think we can do much here though: We can't change older Qt versions anymore, and the warning itself is legit.
-
Ah, OK you are right. It is limited to release mode. When switching to debug and rerun qmake it is gone.
The only solution would be to have different diagnostic configurations per kit.
At the moment I have added "-Wno-zero-as-null-pointer-constant" to a copy of the built-in settings. This solves the problem with the warning at the time being.