Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Errors [unknown type name 'import'], etc.
Forum Updated to NodeBB v4.3 + New Features

Errors [unknown type name 'import'], etc.

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 5 Posters 827 Views 3 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.
  • F Offline
    F Offline
    Frenchy
    wrote on last edited by
    #1

    Hello!

    Environment

    • Mac Mini M4;
    • Sequoia 15.3;
    • Commands Tools installed thanks to xcode-select --install command.
    • Qt Creator 15.0.1. Based on Qt 6.8.1 (Clang 15.0 (Apple), arm64)

    clang --version

    The “clang --version” command displays :
    Apple clang version 16.0.0 (clang-1600.0.26.6)
    Target: arm64-apple-darwin24.3.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin

    xcode-select -print-path displays
    /Library/Developer/CommandLineTools

    Note: whether Xcode is fully installed or not, doesn't solve the problem.

    The program

    This first program, which is supposed to use C++23, displays the following error:

    import std;
    int main()
    {
        std::println(“Hello”);
    }
    

    CMakeLists.txt

    CMakeLists.txt has been defined as follows:

    cmake_minimum_required(VERSION 3.16)
    project(CPPBasic LANGUAGES CXX)
    set(CMAKE_CXX_STANDARD 23)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    add_executable(CPPBasic main.cpp)
    

    Errors displayed

    error: unknown type name 'import'
    error: 'std' is not a class, namespace, or enumeration
    error: Module 'std' not found
    

    My question

    What is the solution for using C++23?
    (Book : Beginning C++23 by I. Horton)

    Thanks for your help.

    jsulmJ Pl45m4P 2 Replies Last reply
    0
    • F Frenchy

      Hello!

      Environment

      • Mac Mini M4;
      • Sequoia 15.3;
      • Commands Tools installed thanks to xcode-select --install command.
      • Qt Creator 15.0.1. Based on Qt 6.8.1 (Clang 15.0 (Apple), arm64)

      clang --version

      The “clang --version” command displays :
      Apple clang version 16.0.0 (clang-1600.0.26.6)
      Target: arm64-apple-darwin24.3.0
      Thread model: posix
      InstalledDir: /Library/Developer/CommandLineTools/usr/bin

      xcode-select -print-path displays
      /Library/Developer/CommandLineTools

      Note: whether Xcode is fully installed or not, doesn't solve the problem.

      The program

      This first program, which is supposed to use C++23, displays the following error:

      import std;
      int main()
      {
          std::println(“Hello”);
      }
      

      CMakeLists.txt

      CMakeLists.txt has been defined as follows:

      cmake_minimum_required(VERSION 3.16)
      project(CPPBasic LANGUAGES CXX)
      set(CMAKE_CXX_STANDARD 23)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      add_executable(CPPBasic main.cpp)
      

      Errors displayed

      error: unknown type name 'import'
      error: 'std' is not a class, namespace, or enumeration
      error: Module 'std' not found
      

      My question

      What is the solution for using C++23?
      (Book : Beginning C++23 by I. Horton)

      Thanks for your help.

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

      @Frenchy Do you get these error when you compile your application?

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

      1 Reply Last reply
      0
      • F Frenchy

        Hello!

        Environment

        • Mac Mini M4;
        • Sequoia 15.3;
        • Commands Tools installed thanks to xcode-select --install command.
        • Qt Creator 15.0.1. Based on Qt 6.8.1 (Clang 15.0 (Apple), arm64)

        clang --version

        The “clang --version” command displays :
        Apple clang version 16.0.0 (clang-1600.0.26.6)
        Target: arm64-apple-darwin24.3.0
        Thread model: posix
        InstalledDir: /Library/Developer/CommandLineTools/usr/bin

        xcode-select -print-path displays
        /Library/Developer/CommandLineTools

        Note: whether Xcode is fully installed or not, doesn't solve the problem.

        The program

        This first program, which is supposed to use C++23, displays the following error:

        import std;
        int main()
        {
            std::println(“Hello”);
        }
        

        CMakeLists.txt

        CMakeLists.txt has been defined as follows:

        cmake_minimum_required(VERSION 3.16)
        project(CPPBasic LANGUAGES CXX)
        set(CMAKE_CXX_STANDARD 23)
        set(CMAKE_CXX_STANDARD_REQUIRED ON)
        add_executable(CPPBasic main.cpp)
        

        Errors displayed

        error: unknown type name 'import'
        error: 'std' is not a class, namespace, or enumeration
        error: Module 'std' not found
        

        My question

        What is the solution for using C++23?
        (Book : Beginning C++23 by I. Horton)

        Thanks for your help.

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @Frenchy said in Errors [unknown type name 'import'], etc.:

        cmake_minimum_required(VERSION 3.16)
        

        What's your CMake version?
        CMake 3.16 is not fulfilling the requirements for C++23 Modules.

        Also, there is a related topic here


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        2
        • F Offline
          F Offline
          Frenchy
          wrote on last edited by Frenchy
          #4

          @jsulm - Do you get these error when you compile your application?
          Immediately upon code entry for “Module ‘std’ not found”.
          Other messages, after compiling.

          Capture d’écran 2025-01-29 à 16.25.25.png

          @Pl45m4 - What's your CMake version?
          Although I searched the web, I couldn't find a way to determine the current version of Cmake.
          I'll take a look at your link.

          Supplementary question

          On Qt Creator version 15, what is the maximum C++ version that can be used?

          Thanks to both of you.

          Pl45m4P C 2 Replies Last reply
          0
          • F Frenchy

            @jsulm - Do you get these error when you compile your application?
            Immediately upon code entry for “Module ‘std’ not found”.
            Other messages, after compiling.

            Capture d’écran 2025-01-29 à 16.25.25.png

            @Pl45m4 - What's your CMake version?
            Although I searched the web, I couldn't find a way to determine the current version of Cmake.
            I'll take a look at your link.

            Supplementary question

            On Qt Creator version 15, what is the maximum C++ version that can be used?

            Thanks to both of you.

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by Pl45m4
            #5

            @Frenchy said in Errors [unknown type name 'import'], etc.:

            I couldn't find a way to determine the current version of Cmake.

            Make it

            cmake_minimum_required(VERSION 3.30)
            

            and try to configure + build.

            You didn't mention your Qt version that you are using.
            (QtCreator 15.0.1 does not say anything about the installed version of the Qt Framework. It's just an IDE that was built with 6.8.1 itself)


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Frenchy
              wrote on last edited by Frenchy
              #6

              @Pl45m4
              Thanks for your answer regarding the cmake_minimum_required.
              The CMake current version is 3.29.3.
              The current Qt version is : Qt 6.8.1 for macOS.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                From the looks of it standard library modules are not supported by Apple's clang.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • F Frenchy

                  @jsulm - Do you get these error when you compile your application?
                  Immediately upon code entry for “Module ‘std’ not found”.
                  Other messages, after compiling.

                  Capture d’écran 2025-01-29 à 16.25.25.png

                  @Pl45m4 - What's your CMake version?
                  Although I searched the web, I couldn't find a way to determine the current version of Cmake.
                  I'll take a look at your link.

                  Supplementary question

                  On Qt Creator version 15, what is the maximum C++ version that can be used?

                  Thanks to both of you.

                  C Offline
                  C Offline
                  ChrisW67
                  wrote on last edited by
                  #8

                  @Frenchy said in Errors [unknown type name 'import'], etc.:

                  On Qt Creator version 15, what is the maximum C++ version that can be used?

                  Qt Creator is an IDE. All it does is simplify running a build process for you. Any limitation comes from the toolchain and libraries you have asked Creator to build your program with. So, the answer is, any version your compiler supports and for which CMake can generate a build process. If you are willing to write your own Makefile then you are not restricted by CMake either.

                  As @SGaist points out, Apple's Clang 16 does not support standard library modules.
                  CMake did not introduce CXX_STANDARD 23 until version 3.20. That would be the earliest version you could expect to even attempt to work; but it can only work if the underlying compilers also have support.
                  In this particular example program there is no involvement of Qt libraries at all.

                  1 Reply Last reply
                  1
                  • F Offline
                    F Offline
                    Frenchy
                    wrote on last edited by
                    #9

                    Thank you all for your precise and relevant answers.
                    Best regards.

                    1 Reply Last reply
                    0
                    • F Frenchy 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