如何在 gcc 中使用模块 `std`

wim*_*aan 2 c++ gcc c++-modules

以下测试程序

import std;
int main() {}
Run Code Online (Sandbox Code Playgroud)

编译为gcc-14

/usr/local/bin/g++  -g -std=c++23 -fconcepts -fmodules-ts -O3 -Wall -Wextra test400.cc --output test400
Run Code Online (Sandbox Code Playgroud)

给出以下错误:

std: error: failed to read compiled module: No such file or directory
std: note: compiled module file is 'gcm.cache/std.gcm'
std: note: imports must be built before being imported
std: fatal error: returning to the gate for a mechanical issue
Run Code Online (Sandbox Code Playgroud)

标准库模块std应该是可用的,但显然不是。

std除了标头单元之外:是我自己创建模块的方法吗?

Chr*_*sMM 6

GCC 的 libstdc++ 尚不支持P2465R3,这允许import std;

https://en.cppreference.com/w/cpp/compiler_support/23

请注意,C++23 尚未最终确定