C++ 模块 "failed to read module 'std.io.gcm': No such file or directory"
C++ Module "failed to read module 'std.io.gcm': No such file or directory"
我正在尝试使用 docker image
测试 C++ 模块
docker pull benboeckel/cxx-modules-sandbox:latest
docker run -it image_id
sh-4.4$ g++ --version
g++ (GCC) 9.0.1 20190301 (experimental) [c++-modules:20190305-1618]
然后,创建一个测试文件。
import std.io;
int main()
{
return 0;
}
我收到以下错误:
sh-4.4$ g++ -o m main.cpp -std=c++2a -fmodules-ts In module imported
at main.cpp:1:1: std.io: error: failed to read module 'std.io.gcm': No
such file or directory std.io: fatal error: jumping off the crazy
train to crashville compilation terminated.
更新:
以下代码工作正常。
//m.cpp
export module M;
export int sq(int i) { return i*i; }
//main.cpp
import M;
int main() { return sq(9); }
g++ -o m main.cpp m.cpp -std=c++2a -fmodules-ts
Modules got added to the C++20 draft, but it doesn't imply that the standard library is now modularized. There's an effort to modularize it,但我们目前还没有任何具体的内容:
While we appear to have achieved consensus on a design for the modules language feature, our plan for how and when the C++ standard library will be modularized are not as mature. Some proposals have been made ([P0581R1] and [P1212R0]) and preliminary discussions have taken place ([2018-Jacksonville-LEWG-P0581R0-Minutes] and [2018-San-Diego-EWG-P1212R0-Minutes]), but we haven’t committed to a path yet. Given that the C++20 cycle is nearly over, it’s time for us to make a decision on our strategy for standard library modules in C++20.
我正在尝试使用 docker image
测试 C++ 模块docker pull benboeckel/cxx-modules-sandbox:latest
docker run -it image_id
sh-4.4$ g++ --version
g++ (GCC) 9.0.1 20190301 (experimental) [c++-modules:20190305-1618]
然后,创建一个测试文件。
import std.io;
int main()
{
return 0;
}
我收到以下错误:
sh-4.4$ g++ -o m main.cpp -std=c++2a -fmodules-ts In module imported at main.cpp:1:1: std.io: error: failed to read module 'std.io.gcm': No such file or directory std.io: fatal error: jumping off the crazy train to crashville compilation terminated.
更新:
以下代码工作正常。
//m.cpp
export module M;
export int sq(int i) { return i*i; }
//main.cpp
import M;
int main() { return sq(9); }
g++ -o m main.cpp m.cpp -std=c++2a -fmodules-ts
Modules got added to the C++20 draft, but it doesn't imply that the standard library is now modularized. There's an effort to modularize it,但我们目前还没有任何具体的内容:
While we appear to have achieved consensus on a design for the modules language feature, our plan for how and when the C++ standard library will be modularized are not as mature. Some proposals have been made ([P0581R1] and [P1212R0]) and preliminary discussions have taken place ([2018-Jacksonville-LEWG-P0581R0-Minutes] and [2018-San-Diego-EWG-P1212R0-Minutes]), but we haven’t committed to a path yet. Given that the C++20 cycle is nearly over, it’s time for us to make a decision on our strategy for standard library modules in C++20.