I read this link https://gcc.gnu.org/wiki/cxx-modules and tried to copy the following example from this website. I already knew that this compiler partially supports the module system. (Note: I used windows)
// hello.cc
module;
#include <iostream>
#include <string_view>
export module hello;
export void greeter(std::string_view const &name) {
std::cout << "Hello " << name << "!\n";
}
// main.cc
import hello;
int main() {
greeter("world");
return 0;
}
// Should print "Hello world!"
I currently have GCC 11.0.1 snapshot and tried to compile these files using the following arguments:
g++ -std=gnu++2b -Wall -fmodules-ts hello.cc main.cc and the compiler gave me these errors:
hello.cc:6:8: internal compiler error: in get_cxx_dialect_name, at cp/name-lookup.c:7027
6 | export module hello;
| ^~~~~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
In module imported at main.cc:1:1:
hello: error: failed to read compiled module: No such file or directory
hello: note: compiled module file is 'gcm.cache/hello.gcm'
hello: note: imports must be built before being imported
hello: fatal error: returning to the gate for a mechanical issue
compilation terminated.
If I compile first the hello.cc, then the compiler still gave errors:
C:\...\hello.cc | 6 | error: failed to write compiled module: No such file or directory |
C:\...\hello.cc | 6 | note: compiled module file is 'gcm.cache/hello.gcm' |
- What should I do?
- Should I just wait for the full support for modules in g++?
- Is there any other way to use it even though g++ partially supports it?