VS 2019 can be twitchy when it comes to modules, one reason why I prefer 2022. Less issues in my experience.
When I rename math.ixx to math.cppm I get the following errors |
You could/should force a full recompile now that you've changed the extension from .ixx to .cppm. Close the project and reopen, and do the full recompile.
If that doesn't work another workaround is to delete the .cppm file from the project and add a new .cppm from the start, copying the code from the old file to the new.
2019 will happily consume .cppm module interface files, after giving it a swift kick in the arse from time to time.
This is MS we are talking about, after all.
By the wording of the error(s) I'd bet VS doesn't recognize the .cppm file as a module interface file, it probably "sees" it as an internal partition file or regular non-module .cpp file.
Are you using command-line compiling and not the IDE? That can also be an issue. I use the IDE. If you are using the IDE check the file's property pages.
Learning how to use modules is enough of a PITA without the distractions VS can sometimes throw at ya with intellisense and other "errors."
The industry is gravitating towards .cppm instead of the MS idea of .ixx. Nice that MS does support the usage, if only in the breach.
.cppm/.ixx is NOT a required extension, it merely informs the IDE and the programmer what the file is to be used for. Manually editing via the file's property pages in the IDE can be done. Internal partition files need to be manually designated in the IDE as an internal partition file, or you get errors up the wazoo.
And don't get me started on the
import std.core;
muck-up. That makes using modules a major "bang head on desk" frustration.
MS's documentation on using modules leaves a lot to be desired. I had unsolvable problems until I got a book on C++20 and plowed my way through it. That made it easier to deal with the minutiae of modules.
Beginning C++ 20: From Novice to Professional From Novice to Professional
https://www.amazon.com/gp/product/1484258835/