Details
-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
None
-
Qt Creator 4.7.2, Qt Creator 4.8.0-rc1
-
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
- relates to
-
QTCREATORBUG-20980 C headers with extern "C" doesn't parse correctly with clang-backend and GCC
- Closed