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. unknown type name 'uintptr_t' when using clang
Forum Updated to NodeBB v4.3 + New Features

unknown type name 'uintptr_t' when using clang

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
8 Posts 3 Posters 2.4k Views 1 Watching
  • 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.
  • Pete CarterP Offline
    Pete CarterP Offline
    Pete Carter
    wrote on last edited by Pete Carter
    #1

    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:

    Screenshot_20230831_070010.png

    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:

    Screenshot_20230831_070556.png

    Any idea how to solve this error ?

    • This error does not happen when using GCC.
    • I installed LLVM and clang.
    jsulmJ 1 Reply Last reply
    0
    • Pete CarterP Offline
      Pete CarterP Offline
      Pete Carter
      wrote on last edited by Pete Carter
      #8

      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

      1 Reply Last reply
      1
      • Pete CarterP Pete Carter

        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:

        Screenshot_20230831_070010.png

        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:

        Screenshot_20230831_070556.png

        Any idea how to solve this error ?

        • This error does not happen when using GCC.
        • I installed LLVM and clang.
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Pete-Carter Does the application build? The code model in QtCreator can produce false errors.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Pete CarterP 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Pete-Carter Does the application build? The code model in QtCreator can produce false errors.

          Pete CarterP Offline
          Pete CarterP Offline
          Pete Carter
          wrote on last edited by
          #3

          @jsulm Yes the app builds successfully. I think the language server has a problem. Any idea how to resolve this error ?

          jsulmJ 1 Reply Last reply
          0
          • Pete CarterP Pete Carter

            @jsulm Yes the app builds successfully. I think the language server has a problem. Any idea how to resolve this error ?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            cristian-adamC 1 Reply Last reply
            0
            • jsulmJ jsulm

              @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.

              cristian-adamC Offline
              cristian-adamC Offline
              cristian-adam
              wrote on last edited by
              #5

              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.

              1 Reply Last reply
              2
              • Pete CarterP Offline
                Pete CarterP Offline
                Pete Carter
                wrote on last edited by Pete Carter
                #6

                @cristian-adam

                C++ Code Model Inspector:

                Screenshot_20230831_144257.png


                Created a bug here

                1 Reply Last reply
                1
                • Pete CarterP Offline
                  Pete CarterP Offline
                  Pete Carter
                  wrote on last edited by
                  #7

                  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)

                  1 Reply Last reply
                  0
                  • Pete CarterP Offline
                    Pete CarterP Offline
                    Pete Carter
                    wrote on last edited by Pete Carter
                    #8

                    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

                    1 Reply Last reply
                    1
                    • Pete CarterP Pete Carter has marked this topic as solved on

                    • Login

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