现代c++学习导论

现代c++学习导论

c++23高级编程 6th(Professional c++ 6th edition)
zlib / 清华 / github

环境的配置

由于MinGW的支持问题,推荐用wsl
1.预编译标准库
g++ -std=c++23 -fmodules-ts -fsearch-include-path -c bits/std.cc
(产生gcm.cache)
2.编译你的程序
g++ -std=c++23 -fmodules-ts main.cpp -o main

或者用cmake来管理模块

//update by 2026/08/31

后来我发现clang++的支持好的多,

clang++ -std=c++23 -stdlib=libc++ \
        /usr/share/libc++/v1/std.cppm \
        -Wno-reserved-identifier \
        -Wno-reserved-module-identifier \
        --precompile -o std.pcm

得到std.pcm,

clang++ -fmodule-file=std=std.pcm -stdlib=libc++ -std=c++23 $fileName -o $fileNameWithoutExt

编译,
注意只能用libc++库,
linux直接用apt下载,windows可以去github下载全家桶

posted @ 2026-08-02 16:52  feng_qi_yun  阅读(11)  评论(0)    收藏  举报