Priority: Not Evaluated
Affects Version/s: Qt Creator 4.6.0
Fix Version/s: Qt Creator 4.8.0-beta1
Component/s: C/C++/Obj-C++ Support
Environment:* gentoo linux
** using clang 6.0 (but I had similar problems with older versions in the past)
* qbs based project, but I think this is broken for other build tools as well
The code model has problems finding files inside clangs resource directory (for example "stddef.h") when the project is using libc++ and a clang kit. See the attachment for a simple qbs based demo project.
When running qt-creator with 'QT_LOGGING_RULES=qtc.clang*=true' I can see the following output:
Libc++ includes "stddef.h" via '#include_next', but because "/usr/lib64/clang/6.0.0/include" is present before "/usr/include/c++/v1" in the search list clang can not find the file.
Note that clang removed the include directory in the correct place because someone inserted the direcotry already at the top of the list.
I think this happens inside qt-creator code in 'CompilerOptionsBuilder::addPredefinedHeaderPathsOptions'. As far as I can tell this is not needed with a recent clang version. Clang will add the resource directory to the search path if needed.
To check this I rebuild qt-creator with the variable 'CLANG_RESOURCE_DIR' inside 'clang_defines.pri' changed to a non existing path - so qt-creator can not add the correct include directory anymore. Then I tried my demo project with different build configurations - they all seem to work correctly. Debug output:
clang kit, using libc++:
clang kit, using stdlibc++:
gcc kit, using stdlibc++: