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.
  • P Offline
    P Offline
    Pete Carter
    wrote on 31 Aug 2023, 04:07 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.
    J 1 Reply Last reply 31 Aug 2023, 05:46
    0
    • P Offline
      P Offline
      Pete Carter
      wrote on 5 Sept 2023, 08:10 last edited by Pete Carter 9 May 2023, 08:11
      #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
      • P Pete Carter
        31 Aug 2023, 04:07

        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.
        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 31 Aug 2023, 05:46 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

        P 1 Reply Last reply 31 Aug 2023, 05:48
        0
        • J jsulm
          31 Aug 2023, 05:46

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

          P Offline
          P Offline
          Pete Carter
          wrote on 31 Aug 2023, 05:48 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 ?

          J 1 Reply Last reply 31 Aug 2023, 05:51
          0
          • P Pete Carter
            31 Aug 2023, 05:48

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

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 31 Aug 2023, 05:51 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

            C 1 Reply Last reply 31 Aug 2023, 11:21
            0
            • J jsulm
              31 Aug 2023, 05:51

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

              C Offline
              C Offline
              cristian-adam
              wrote on 31 Aug 2023, 11:21 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
              • P Offline
                P Offline
                Pete Carter
                wrote on 31 Aug 2023, 11:43 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
                • P Offline
                  P Offline
                  Pete Carter
                  wrote on 1 Sept 2023, 11:03 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
                  • P Offline
                    P Offline
                    Pete Carter
                    wrote on 5 Sept 2023, 08:10 last edited by Pete Carter 9 May 2023, 08:11
                    #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
                    • P Pete Carter has marked this topic as solved on 5 Sept 2023, 08:11

                    2/8

                    31 Aug 2023, 05:46

                    topic:navigator.unread, 6
                    • Login

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