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

C headers sometimes fail with clang language model when using clang compiler

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • None
    • Qt Creator 4.7.2, Qt Creator 4.8.0-rc1
    • C/C++/Obj-C++ Support
    • Arch Linux
      Clang 7.0.0
      GCC 8.2.1

    Description

      Under some project configurations, C headers will fail to parse properly with clang language model. This tends to happen with stdint types, such as uint32_t. I've been able to narrow it down to the following conditions:

      • clang is selected as the compiler under the kit configuration. (I tested with Linux with clang-7 installed)
      • In some cases the header fails with the "Active Parse Context" to "C". In this case, it's related to setting CMAKE_CXX_STANDARD to 11 in CMakeLists.txt.
      • In some cases the header fails with the "Active Parse Context" to "C++". In this case, it's related to setting CMAKE_C_STANDARD to 11 in CMakeLists.txt.

       

      Note how the language standard is actually the opposite of the parse context chosen when this issue occurs.

       

      I have attached a small project that exhibits this behavior. If you open it in Qt Creator and view test.h, notice how it will complain about unknown type name uint32_t when the "Active Parse Context" is set to "C". This is chosen by default in Qt Creator 4.8 RC 1. In Qt Creator 4.7.2 the "Active Parse Context" defaults to "C++" and doesn't exhibit the issue, but if you manually switch it to "C" you can reproduce the problem. Switching the kit to GCC or commenting out the line "set(CMAKE_CXX_STANDARD 11)" in CMakeLists.txt will work around the issue.

       

      If you rename "test.cpp" to "test.c" (and update CMakeLists.txt accordingly), the problem is inverted: it will fail to parse when "Active Parse Context" is set to "C++" and you can work around the issue by commenting out the line "set(CMAKE_C_STANDARD 11)"

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kosjar Nikolai Kosjar
              akb825 Aaron Barany
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes