Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Reducing the number of warning in Qt Creator when editing plain C code
Sometime I need to use the Qt Creator as IDE to edit plain C code.
Using QT Creator 4.7.1 the number of warnings / errors shown editing the code is confusing.
Here is an example:
Is it possible to reduce the number of false positives or, on the worst case to disable everything on a project basis ?
JonB last edited by
This is purely a hazarded guess....
I used Qt Creator a while ago for pure C and did not have any such problems. All 3 of your warnings would come from failing to find/process your
#includes correctly. Are you sure it is finding them (some kind of "INCLUDE" path) and pre-processing them with correct defines?
@JonB Qt Creator itself recognizes the includes. Typing F2 over a symbol (like fprintf) go to the definition in stdio.h. It seems that the clang-model or some of the other new syntax tools is not able to analyse the includes, or analyses them with wrong parameters.
you are fully right, some headers drive Clang crazy and lead to situations like yours or QTCREATORBUG-20039.
I sometimes manage to fix my includes so the errors disappear, but with system includes thats hardly manageable.
but if you have minimal examplesthat trigger this, then you can create bugreports so we hopefully get this fixed.
@JonB Thats correct, but Clang is very picky and gets to error states even you did all right.
the old code model was more relaxed in that regard.
@aha_1980 I will try to file a bugreport on Sunday... It takes a lot of work to do it.
In the meantime I switched to an older version of Qt Creator.
Doing that one have to remember to use the -settingspath option to avoid to damage the configuration of the current version.
If you are really unhappy, it might be enough to disable Clang Code Model in newer Creator: Help > About Plugins > Clang Code Model.
I'll try to update QTCREATORBUG-20039 soon also, but as you said, that's quite some work to produce good examples. I think if this bug is fixed, most of your problems should disappear also.
@aha_1980 I think me too it is all related. My impression is that Clang get confused on the __BEGIN_DECLS instruction in the include, but we cannot cheat defining correctly the instruction because it has some "a priori" knowledge.
Yes, disabling Clang Code Model may be an option, but it is a global option. and working in C++ the Clang Code Model makes a good service, even if I still wasn't able to turn off a single warning on a specific line...
@rrossi it seems that version 4.7.2 of Qt Creator solved the problem