unknown type name 'uintptr_t' when using clang
-
My sys info:
Operating System: Fedora Linux 38 KDE Plasma Version: 5.27.7 KDE Frameworks Version: 5.109.0 Qt Version: 5.15.10 Kernel Version: 6.4.12-200.fc38.x86_64 (64-bit) Graphics Platform: Wayland
I have been trying to use Clang instead of GCC. When i enable Clang, i get this error:
The error in text:
main.cpp:3:10: In included file: unknown type name 'uintptr_t'; did you mean 'intptr_t'? shared_ptr_atomic.h:506:24: error occurred here unistd.h:267:20: 'intptr_t' declared here
This is my clang config:
Any idea how to solve this error ?
- This error does not happen when using GCC.
- I installed LLVM and clang.
-
I used the system version of clangd installed in
/usr/bin/clangd
instead of the version shipped with QtCreator. Now it works fine and no errors.The path of the system clangd version can be changed in
Edit -> Preferences -> C++ -> clangd
-
@Pete-Carter Does the application build? The code model in QtCreator can produce false errors.
-
@Pete-Carter I don't know how to properly solve this. I think you can disable the CLang plug-in to get rid of such errors. But of course you will not have CLang warning/errors in QtCreator then which can be helpful.
-
Please do create a bugreport at https://bugreports.qt.io/
Qt Creator uses
clangd
for the C++ code model, which means that clang will be doing some "compilation" of the source code.In order to get this clang to work with gcc Qt Creator will use some of its own includes found at
qtcreator/bin/clang/lib/clang/16/include
(on Linux the path could be different).At https://wiki.qt.io/Qt_Creator_Clang_Code_Model there is some information about how to tweak the code model a bit.
Under
Tools > Debug Qt Creator > Inspect C/C++ Code Model
you could have a look at how the "Header Paths" are taken into consideration by the C++ code model.Qt Creator should be able to work fine with clang too.
-
-
I discovered that this problem happens only when using C++20.
By default the new projects are using C++17:
hello_world.pro
:TEMPLATE = app CONFIG += console c++17 CONFIG -= app_bundle CONFIG -= qt SOURCES += \ main.cpp
When changing
CONFIG += console c++17
to
CONFIG += console c++20
The error messages appears in
main.cpp
. The code compiled fine tho.Clang version:
16.0.6 (Fedora 16.0.6-2.fc38)
-
I used the system version of clangd installed in
/usr/bin/clangd
instead of the version shipped with QtCreator. Now it works fine and no errors.The path of the system clangd version can be changed in
Edit -> Preferences -> C++ -> clangd
-
P Pete Carter has marked this topic as solved on