[Qt-creator] clang code model for syntax highlighting does not work for standard header
fgf
fgf at gmx.net
Sat Jul 15 12:57:23 CEST 2017
Hi,
I try to use syntax highlighting with the clang code model.
Unfortunately, the header of the standard library, for instance,
<vector>, <string> etc. are not recognized.
For example, in this simple file sin, cout, namespace std, endl are not
recognized. The file itself compiles ok.
---------------------------------------
#include <QCoreApplication>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
double x = sin(1.0);
cout << x << endl;
return a.exec();
}
-----------------------------------------
There is a warning that the code model could not parse an included file.
Partly, it is possible to fix this by adding explicit include
statementsto the *.pro-file, but even then I run into problems in more
complex cases (for instance for <string> header), which requires the
addition of additional path'. Furthermore, it is not desirable to add
absolute path names to *.pro-file.
-----------------------------------------
QT -= gui
CONFIG += console
CONFIG -= app_bundle
INCLUDEPATH += /usr/include/c++/7.1.1
INCLUDEPATH += /usr/include/c++/7.1.1/x86_64-pc-linux-gnu
QMAKE_CXXFLAGS += -std=c++14
SOURCES += main.cpp
-------------------------------------------
These observations suggests that clang does not know the path of the
standard headers. Is there a way to circumvent this problem in a more
elegant way? Is there are simple way to provide the clang plugin with
the correct path?
i use Qt Creator 4.3.1 in Manjaro Linux with GCC 7.1.1. A late snapshot
of the beta of 4.4 has a similar problem.
More information about the Qt-creator
mailing list