I can't get the c++20 modules to work, I get this message -> [Note] C++20 'import' only available with '-fmodules-ts', which is not yet enabled with '-std=c ++20'
I am using the devc++ ide of this page.
https://www.embarcadero.com/es/free-tools/dev-cpp
And the w64devkit compiler from this page.
https://github.com/skeeto/w64devkit/releases
You probably will need to add -fmodules-ts to your compile options, but I do not know how to that with your IDE.
.cpp
import persona; #include <iostream> int main(){ Persona persona{ 21,80.20 }; std::cout<<"edad: "<<persona.get_edad()<<"\n"; std::cout<<"peso: "<<persona.get_peso()<<"\n"; std::cout<<"modulos"<<"\n"; return 0; }
.cppm
This is the code that I am using for the test, I have used the -fmodules-ts command, in the tools options/compiler options but it still does not work
For it to work in Visual Studio I had to add module; at the top of the module file, like this:
It doesn't work either, I get these messages:
[Error] failed to read compiled module: No such file or directory
[Note] compiled module file is 'gcm.cache/persona.gcm'
[Note] imports must be built before being imported
[Error] returning to the gate for a mechanical issue
Edited: it must be that your IDE needs additional parameters to build the module before using it in main…
It may be but without knowing how it cannot be used.
If you really want to use c++20 and modules, you may want to use a more complete IDE, like Visual Studio...