Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Clang Code Model fails to find header files
QtWS25 Last Chance

Clang Code Model fails to find header files

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
3 Posts 2 Posters 3.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    camm
    wrote on last edited by
    #1

    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?

    aha_1980A 1 Reply Last reply
    0
    • C camm

      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?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 has to stay free or it will die.

      aha_1980A 1 Reply Last reply
      0
      • aha_1980A aha_1980

        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

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        The bugreports are now:

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

        Qt has to stay free or it will die.

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved