namespace cpp {}

C++ lernen, kennen, anwenden

Benutzer-Werkzeuge

Webseiten-Werkzeuge


howto:module_std_gcc15

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
howto:module_std_gcc15 [2025-03-08 16:34] rrichterhowto:module_std_gcc15 [2025-04-27 09:33] (aktuell) – [How to use C++ module std in GNU g++-15] rrichter
Zeile 1: Zeile 1:
 ====== How to use C++ module std in GNU g++-15 ====== ====== How to use C++ module std in GNU g++-15 ======
  
-Modules with g++15 HEAD, CMake and Ninja under Windows 10. Warning: This is experimental.+Modules with g++15, CMake and Ninja under Windows 10. Warning: This is experimental.
  
 A small demo project. Available on [[https://github.com/rene-richter/cpp_module_std_cmake_gcc15HEAD|Github]]. A small demo project. Available on [[https://github.com/rene-richter/cpp_module_std_cmake_gcc15HEAD|Github]].
Zeile 15: Zeile 15:
 Prerequisites: Prerequisites:
  
-  * GCC 15 HEAD https://www.equation.com gcc-15-2024-1215-64.exe+  * g++ 15.1 (just released!) or [[https://www.equation.com/servlet/equation.cmd?fa=fortran|g++ 16 HEAD]]
   * CMake 3.31.3   * CMake 3.31.3
   * Ninja 1.12.1   * Ninja 1.12.1
  
-Limitations (at the time of writing, 2025-02-21):+Limitations (at the time of writing, 2025-04-25):
  
   * CMake supports C++ modules for Ninja generator only   * CMake supports C++ modules for Ninja generator only
-  * CMake tells Ninja nothing about module std. Hack: extra library ''%%module_std%%'' in ''%%CMakeList.txt%%''+  * CMake tells Ninja nothing about module std. (I wasn't able to get[[https://www.kitware.com/import-std-in-cmake-3-30/|Kitware's "import std" recipe]] running.) Hack: extra library ''%%module_std%%'' in ''%%CMakeList.txt%%''
- +  Some features like ''std::print()'' or ''std:stacktrace'' are in GCC's experimental library ''stdc++exp''.
-Some lines in source file ''%%gnu/std.cc%%'' (copied from ''%%MinGW/include/c++/15.0.0/bits/std.cc%%'') had to be commented out: +
- +
-<code cpp> +
-// using std::aligned_alloc; +
-// using std::timespec; +
-// using std::timespec_get; +
-// using std::mbrtoc8; +
-// using std::c8rtomb; +
-</code> +
-Sadly, newer weekly build compiler ''%%https://www.equation.com/ftpdir/gcc-15-20250202-64.exe%%'' resulted in compilation error: ''%%exposes TU-local entity%%'':-(+
  
 ==== CMake ==== ==== CMake ====
Zeile 45: Zeile 35:
     LANGUAGES CXX)     LANGUAGES CXX)
  
-# temporary hack for GCC g++15.0 HEAD https://www.equation.com gcc-15-20241215-64.exe+hack #1: temporary hack for GCC g++16.0 HEAD https://www.equation.com gcc-15-20250420-64.exe
 # to remove when g++ & CMake know about module std # to remove when g++ & CMake know about module std
 add_library(module_std) add_library(module_std)
Zeile 52: Zeile 42:
     PUBLIC     PUBLIC
         FILE_SET CXX_MODULES FILES         FILE_SET CXX_MODULES FILES
-            gnu/std.cc # modified from MinGW\include\c++\15.0.0\bits\std.cc+            gnu/std.cc # copied from MinGW\include\c++\16.0.0\bits\std.cc
 ) )
 target_compile_features(module_std PUBLIC cxx_std_26) target_compile_features(module_std PUBLIC cxx_std_26)
Zeile 58: Zeile 48:
 # target_link_libraries(...XYZ... PRIVATE module_std) # target_link_libraries(...XYZ... PRIVATE module_std)
  
-another hack for advanced features like std::print(), std::stacktrace, etc in g++14 and g++15.0 HEAD:+# hack #2: advanced features like std::print(), std::stacktrace, etc in g++14g++15, and g++16 HEAD:
 # target_link_libraries(...XYZ... PRIVATE stdc++exp) # target_link_libraries(...XYZ... PRIVATE stdc++exp)
  
Zeile 69: Zeile 59:
 ) )
 target_compile_features(my_module PUBLIC cxx_std_26) target_compile_features(my_module PUBLIC cxx_std_26)
-target_link_libraries(my_module PRIVATE module_std)+target_link_libraries(my_module PRIVATE module_std) # hack #1
  
 add_executable(demo src/demo.cpp) add_executable(demo src/demo.cpp)
 target_compile_features(demo PUBLIC cxx_std_26) target_compile_features(demo PUBLIC cxx_std_26)
-target_link_libraries(demo PRIVATE module_std) 
 target_link_libraries(demo PRIVATE my_module) target_link_libraries(demo PRIVATE my_module)
-target_link_libraries(demo PRIVATE stdc++exp)+target_link_libraries(demo PRIVATE module_std) # hack #1 
 +target_link_libraries(demo PRIVATE stdc++exp)  # hack #2
  
 </code> </code>
howto/module_std_gcc15.1741448074.txt.gz · Zuletzt geändert: 2025-03-08 16:34 von rrichter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki