Clang Code Model fails to find header files



  • I'm running Clang v5.0.1, originally on Qt Creator 4.5.0, but it behaves the same on 4.6.0 Beta1-1840. A simple hello-world application:

    #include <iostream>
    
    int main(int, char*[])
    {
        std::cout << "Hello World" << std::endl;
        return EXIT_SUCCESS;
    }
    

    This obviously compiles and runs file under GCC, but the CCM marks every line as some kind of error. Enabling CCM debug for Qt Creator reveals some interesting things, firstly Clang cannot seem to find a header file despite looking in the correct place:

    ...
    #include "..." search starts here:
    #include <...> search starts here:
     /home/cmannett85/workspace/qtcreator-4.6.0-beta1/libexec/qtcreator/clang/lib/clang/5.0.1/include
     /home/cmannett85/workspace/qtcreator-4.6.0-beta1/share/qtcreator/cplusplus/wrappedQtHeaders
     /home/cmannett85/workspace/qtcreator-4.6.0-beta1/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore
     /home/cmannett85/workspace/calrec/scratch
     /home/cmannett85/workspace/calrec
     /usr/local/include
     /usr/include
     /usr/include/c++/7
     /usr/include/c++/7/x86_64-redhat-linux
     /usr/include/c++/7/backward
     /usr/lib/gcc/x86_64-redhat-linux/7/include
     /tmp/QtCreator-mBdlxZ/clang-uiheader-UUGInf
    End of search list.
    Parsing /home/cmannett85/workspace/calrec/scratch/main.cpp:   0.1768 (100.0%)   0.0106 (100.0%)   0.1874 (100.0%)   0.1895 (100.0%)  
    /usr/include/c++/7/cstdlib:75:15: fatal error: 'stdlib.h' file not found
    ...
    

    stdlib.h is in /usr/include, but for some reason Clang just doesn't see it.

    On a side note, the language version flag passed to Clang is C++11 (the default), but I actually want to use C++14 - but I'm using a Makefile-based project. How do I tell Clang what language version to use when using a Makefile-based project?


  • Qt Champions 2018

    Hi @camm,

    On a side note, the language version flag passed to Clang is C++11 (the default), but I actually want to use C++14 - but I'm using a Makefile-based project. How do I tell Clang what language version to use when using a Makefile-based project?

    The Generic Projects (= Makefile-based projects) have not much more than a list of files right now. I doubt there is a configuration for the language version yet, but I may be wrong.

    Regarding the includes: If you have such a small reproduceable example, I'd file this as bug at bugreports.qt.io

    The language setting could be a separate suggestion (if there is not already one).

    Regards


  • Qt Champions 2018

    The bugreports are now:

    QTCREATORBUG-19667 for the headers
    QTCREATORBUG-19668 for the language specification


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.