c++ 模块
import std;
auto main() -> int {
std::println("Hello World!");
return 0;
}
编译
wget https://ftp.gnu.org/gnu/gcc/gcc-15.1.0/gcc-15.1.0.tar.gz
tar xf gcc-15.1.0.tar.gz
cd gcc-15.1.0
./contrib/download_prerequisites
mkdir build
cd build
../configure \
--prefix=/usr/local/gcc-15.1.0 \
--program-suffix=-15 \
--enable-languages=c,c++ \
--disable-multilib \
--disable-bootstrap
make -j$(nproc) _# 使用所有CPU核心加速编译_
sudo make install
export PATH=/usr/local/gcc-15.1.0/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/gcc-15.1.0/lib64:$LD_LIBRARY_PATH
g++-15 -std=c++23 -fmodules -c -fmodule-only -fsearch-include-path bits/std.cc
g++-15 --std=c++23 -fmodules main.cc -o test -Wall