Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
Qt Creator 3.6.0
-
None
-
Windows 7, Visual C++ 2015
Description
clang diagnostic hints do not seem to work correctly with precompiled headers
at least with Visual C++ 2015 compiler and some style of writing
For project files ...
// stdafx.h
#include <string>
—
// stdafx.cpp
#include "stdafx.h"
using std::string;
—
// thing.h
class thing
;
—
// thing.cpp
#include "stdafx.h"
#include "thing.h"
// ...
—
... build works normally, no errors or warnings, therefore, apart from style, this is okay for compiler.
In QtCreator, however, with thing.h file open in editor, it shows an error: unknown type name 'string', which looks like the precompiled header is ignored.
THERE SHOULD NOT BE A DIFFERENCE BETWEEN WHAT COMPILER CAN DIGEST AND WHAT ANALYZER IS SAYING ABOUT IT.
By definition of precompiled header in MSVC, everything what is above #include "stdafx.h" is ignored, then the content of precompiled header is pasted in. (simplified explanation)
Also it seems to me like thing.h is analyzed on it's own, separately from everything, neglecting thing.cpp, although the compilation unit, AFAIK, is a source file, not a separate header file.
Should thing.h be analyzed as a part of source file, then, before inclusion of thing.h, stdafx.h is included and everything used in thing.h is declared and defined.
I tried to force include by -include stdafx.h in Options/.../clang code model, with either relative or absolute path, but with no luck, my header files are flooded by dozens of red marks and there is no way to turn it off. Which is unusable.
And, of course, I have a precompiled header clause in my project file, being it either qmake or qbs.
I found a reference on an internet to some "new page in projects mode related to clang code model" but did not find it in my QtCreator 3.6.0, so I assume this was applicable to some older version.
Attachments
For Gerrit Dashboard: QTCREATORBUG-15590 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
175504,4 | Clang: Take precompiled headers into account when parsing source files | 4.2 | qt-creator/qt-creator | Status: MERGED | +2 | 0 |