Reputation: 1197
I have this program I am trying to compile. Live here
import std.core;
int main()
{
std::cout<<"ravioli";
}
I was reading about Modules in C++ 20. The source has only information about running it on Microsoft C++ compiler. Has any other compiler implemented modules yet? If yes what additional flags do I need for this program to compile.
Upvotes: -2
Views: 500
Reputation: 128
With the compiler (x86-64 gcc 13.2) and switch (-std=c++23) this is the error that occurs:
<source>:2:1: error: 'import' does not name a type
2 | import std.core;
| ^~~~~~
<source>:2:1: note: C++20 'import' only available with '-fmodules-ts', which is
not yet enabled with '-std=c++20'
When the switch (-fmodules-ts) is added, the error is as:
std.core: error: failed to read compiled module: No such file or directory
std.core: note: compiled module file is 'gcm.cache/std.core.gcm'
std.core: note: imports must be built before being imported
std.core: fatal error: returning to the gate for a mechanical issue
Since this code is compiling in isloation without any imported std core (See the diagnostic above: imports must be built before being imported) the above diagnostics occur. You can download the GCC v13 and higher and rebuild the std core then rebuild this code with the rebuilt core.
If you want to do away with module feature in the latest GCC, you could simply rewrite:
#include <iostream>
int main()
{
std::cout<<"ravioli";
return 0;
}
Upvotes: 0
Reputation: 56
According to one of STL devs in Reddit, the stl
modules like stl.core
or stl.io
are just a Microsoft thing and is intended as a starting point for a C++23 proposal. They're just a repackaging of the existing Standard Library with no organizational changes other than dividing them into five or so groups. You can found more about this in the Overview of modules in C++ or in the OpenSTD paper.
Upvotes: 1