Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-20602

Clang code model does not read "-include" compiler flag

XMLWordPrintable

    • 888ea6bbbb0f4c6bb6b5616046e600b9520e4faf (qt-creator/qt-creator/master)

      Summary
      If "-include" gets added to CMAKE_CXX_FLAGS in CMakeLists.txt, clang code model does not seem to use this flag, and subsequently reports incorrect errors caused by missing headers.

      Minimal example

      CMakeLists.txt

      cmake_minimum_required(VERSION 2.8)
      
      project(codeModelBug)
      
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${CMAKE_SOURCE_DIR}/pch.h")
      
      add_executable(codeModelBug main.cpp)
      

      main.cpp

      int main()
      {
          // clang code model: error: use of undeclared identifier 'helloWorld'
          helloWorld();
          return 0;
      }
      

      pch.h

      #pragma once
      
      #include <iostream>
      
      inline void helloWorld()
      {
          std::cout << "Hello World!" << std::endl;
      }
      

       

      The example can also be found as .zip in the Downloads.

      The example compiles and executes fine. Just the clang code model and the syntax completion fail to find the helloWorld function.

        1. codeModelBug.zip
          1.0 kB
          Martin Stumpf
        For Gerrit Dashboard: QTCREATORBUG-20602
        # Subject Branch Project Status CR V

            kandeler Christian Kandeler
            mstumpf Martin Stumpf
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes