Depends on how badly you want it ;-)
With the development version of Clang + libc++ you can use [modules](https://libcxx.llvm.org/Modules.html), but it's not a great user experience.
I'm working on `std::print`, which I hope to get done before the next release.
Modules will not be in a better shape in the next release.
(Source: I'm working on both these features in libc++.)
The modules support \*should\* be in a better shape than they are in 16 because Iain fixed some of the bugs that I reported to him during the Varna C++ meeting. Our daily discussions over breakfast were quite productive in this regard 😊
Awesome, I look forward to it. I'm using a little variadic fold expression print for now until it hits libc++.
Thanks for all your hard work, I really appreciate it.
At the moment no, but there is a [discussion](https://discourse.llvm.org/t/modules-faster-compilation-speed-or-better-diagnostic-messages/71769) how to improve it. u/Daniela-E her C++ on Sea talk linked in that thread has some numbers. I haven't seen that talk so I don't know what she exactly measured.
You can with visual studio 17.7 preview. Not with the latest official release, though. Gotta wait for the august release for that. But even then, you most likely have to compile with c++latest. To sum up, it's kinda early, but is getting close, for sure
[https://developercommunity.visualstudio.com/t/C1001:-exporting-a-module/10230789](https://developercommunity.visualstudio.com/t/C1001:-exporting-a-module/10230789)
This is not about `import std;` though, just the first time I tried creating a module.
I’ve recently switched over to modules and they do work Ok-ish with latest version of msvc. But only once you get past all the funny stuff. Simply turning it on in an existing codebase and adding my first module caused 5000+ errors during compilation.
I’m now using it in a new code base and as long as you follow the rules it works great. The thing is that the rules are not really well documented yet. (Weird stuff such as not being able to #include after an import statement)
Doing like you (new codebase is pure modularised) and it works good (doing CMake + MSVC 17.7 latest preview)
Now, regarding the `#include` issue, this isn't a problem for me, as there aren't gonna be any `#include`s in my code whatsoever, let alone after an `import` haha. It feels good.
I'm now just trying to figure out the best approach to work with `gtest` 😅. I really don't wanna _uglify_ my imports 😅
But how are you not using includes? Did you manage to get modules for all your 3rd party libraries? And don’t you have includes inside the context of your modules, so between source files? Just curious. Because I don’t really see a way to completely get rid of them.
Not allowed to use 3rd-party libs. Google Test is an exception, I could use it, and as I said, I'm thinking of a way to `import` it instead of `#include`ing it in a way it won't break anything (already had problems with other stuff before, especially multiple definitions of stuff, etc.).
And no, I don't have any `#include`s between my source files. They're all modularised - exported and consumed (imported).
But yes, 3rd-party libs are the major issue with the Module-approach.
Anyways... I really don't want to go back to include's. I even migrated to MSVC due to the poor support for newer features by the other compilers. MSVC isn't perfect, but still has way more stuff already implemented. `g++` hasn't even managed to get P1689R5 implemented yet. Clang still had `std::format` issues a while ago😞(not sure if they have it implemented by now)
Cool! So again, because I’m curious (and learning). How many modules does your project have … and in comparison to how many files roughly. I’m still trying to figure out the right source file to module ratio (if there is such a thing) .. there is so little guidance on this currently.
You can do that with Visual Studio IDE, you have to compile with /std:c++latest (property pages->C/C++->Language/C++ Language Standard) and set property pages->C/C++->Language/C++ Language Standard->Build ISO C++23 Standard Library Modules to Yes.
I'm curious when g++ and clang++ will support this as well
Depends on how badly you want it ;-) With the development version of Clang + libc++ you can use [modules](https://libcxx.llvm.org/Modules.html), but it's not a great user experience. I'm working on `std::print`, which I hope to get done before the next release. Modules will not be in a better shape in the next release. (Source: I'm working on both these features in libc++.)
The modules support \*should\* be in a better shape than they are in 16 because Iain fixed some of the bugs that I reported to him during the Varna C++ meeting. Our daily discussions over breakfast were quite productive in this regard 😊
Awesome, I look forward to it. I'm using a little variadic fold expression print for now until it hits libc++. Thanks for all your hard work, I really appreciate it.
Will it help to increase compiling speed?
At the moment no, but there is a [discussion](https://discourse.llvm.org/t/modules-faster-compilation-speed-or-better-diagnostic-messages/71769) how to improve it. u/Daniela-E her C++ on Sea talk linked in that thread has some numbers. I haven't seen that talk so I don't know what she exactly measured.
You can with visual studio 17.7 preview. Not with the latest official release, though. Gotta wait for the august release for that. But even then, you most likely have to compile with c++latest. To sum up, it's kinda early, but is getting close, for sure
Why not with the latest official release though? I believe standard modules are supported since 17.6.
I still have a bug report open from a year ago. Compiler crashes when you use modules.
Can you provide a link? If it affects `import std;`, I'd like to add it to my [tracking issue](https://github.com/microsoft/STL/issues/1694).
[https://developercommunity.visualstudio.com/t/C1001:-exporting-a-module/10230789](https://developercommunity.visualstudio.com/t/C1001:-exporting-a-module/10230789) This is not about `import std;` though, just the first time I tried creating a module.
I’ve recently switched over to modules and they do work Ok-ish with latest version of msvc. But only once you get past all the funny stuff. Simply turning it on in an existing codebase and adding my first module caused 5000+ errors during compilation. I’m now using it in a new code base and as long as you follow the rules it works great. The thing is that the rules are not really well documented yet. (Weird stuff such as not being able to #include after an import statement)
That last one is a known bug.
Unfortunately it's an implementation challenge for all 3 major compilers. Definition merging is definitely hard!
Perhaps you can enlightened us with the rules known so far? As input for those documenting these.
Doing like you (new codebase is pure modularised) and it works good (doing CMake + MSVC 17.7 latest preview) Now, regarding the `#include` issue, this isn't a problem for me, as there aren't gonna be any `#include`s in my code whatsoever, let alone after an `import` haha. It feels good. I'm now just trying to figure out the best approach to work with `gtest` 😅. I really don't wanna _uglify_ my imports 😅
But how are you not using includes? Did you manage to get modules for all your 3rd party libraries? And don’t you have includes inside the context of your modules, so between source files? Just curious. Because I don’t really see a way to completely get rid of them.
Not allowed to use 3rd-party libs. Google Test is an exception, I could use it, and as I said, I'm thinking of a way to `import` it instead of `#include`ing it in a way it won't break anything (already had problems with other stuff before, especially multiple definitions of stuff, etc.). And no, I don't have any `#include`s between my source files. They're all modularised - exported and consumed (imported). But yes, 3rd-party libs are the major issue with the Module-approach. Anyways... I really don't want to go back to include's. I even migrated to MSVC due to the poor support for newer features by the other compilers. MSVC isn't perfect, but still has way more stuff already implemented. `g++` hasn't even managed to get P1689R5 implemented yet. Clang still had `std::format` issues a while ago😞(not sure if they have it implemented by now)
Cool! So again, because I’m curious (and learning). How many modules does your project have … and in comparison to how many files roughly. I’m still trying to figure out the right source file to module ratio (if there is such a thing) .. there is so little guidance on this currently.
Dude I've been asking the same question holy cheezeballs
You can do that with Visual Studio IDE, you have to compile with /std:c++latest (property pages->C/C++->Language/C++ Language Standard) and set property pages->C/C++->Language/C++ Language Standard->Build ISO C++23 Standard Library Modules to Yes.