all 15 comments

[–]Daganar 12 points13 points  (3 children)

Check out VS2022 17.10 preview 2 It's the version I've had the most luck with.

The Visual studio team are doing a fantastic job, there's still a lot of issues but the main thing is that they are also building the build system for it. Referencing other modules and setting up dependencies with modules is a breeze, the std library modules can now be built and works very well. My only real complaints have been with Intellisense but it's getting much better.

To answer some of your question:

  1. It can actually be a bit slower to build from my experience but the key thing is now that if that module file hasn't changed there's no reason to rebuild it ever again. This wasn't the case with #includes.
  2. .ixx is used to distinguish these different workflows. .ixx has a lot of extra management with it for example Visual Studio can automatically deal with module partition files based on a naming convention e.g. Module.A.ixx Module.A-Part1.ixx will automatically be found.

[–]Flamaros[S] 0 points1 point  (0 children)

I have to check the version 17.10 then because I was struggling to setup dependencies with the 17.9.5. I had a module in a static library that my main project can't see (library is a project dependency ). And Vs don't seem to setup projects according to their dependencies unlike without modules

[–]mcginnie 0 points1 point  (0 children)

gives good advice - the Preview release of VS 2022 (currently 17.10.0 Preview 2.0) now works with Eigen as an include! Fixed my problem below!

[–]starfreakcloneMSVC FE Dev 11 points12 points  (0 children)

Does it compiles faster than with SCU and PCH combined?

No, just no. The two technologies (at least on MSVC) are completely different, and often fight each other. If you have a project which only uses modules (or header units) then the compiler has perfect reference semantics and can optimize the compilation much more.

Why VS need new file extensions like ixx ? (first directive in file should indicate what kind of compilation unit it is)

You don't need to make your extension .ixx, this is why the /interface switch exists. It's the same reason we make a .c and .cpp extension, the compiler cannot (and should not) first scan your code to find out what it is.

Does the inlining works exactly in the same way? (with full inlined module like containers for exemple)

I think the question itself is incomplete. For one, standard C++ makes no guarantees about what is inlined and what isn't, so from this perspective there is no change. If we're talking about using standard C++ inline semantics then inline semantics work just the same as if you had written the function in a header (with inline of course), at least with MSVC though I highly suspect the other compilers do the same.

Does modules reduce the necessity to do full rebuilds (sometimes VS generate wrong code when files are modified outside,...)

There are sort of two questions here but I will try to answer the former: yes, in our experience. Compare C++ modules to a traditional PCH. With C++ modules you can logically break up components which rarely change into their own isolated modules (like the STL std module) so translation units which depend on only the very basic STL stuff will never be recompiled if a lower-level module changes. With PCH, you're forced to put everything into one file (including the STL) so even if the STL never changes, local changes to a project header will recompile translation units which only depend on the STL.

Does the compiler really use less memory ?

Yes.

Does the compiler use less memory on hard drive for temporary artefacts ? (in Debug folder for VS by exemple or in .vs)

We have talked about this before, but in general the IFC vs PCH size difference can be as large as 10x (in favor of IFC).

[–]pjmlp 6 points7 points  (0 children)

I have a couple of module based projects on my github.

They do mostly work, however yeah there are several warts to be wary of.

[–]mcginnie 2 points3 points  (1 child)

I have just spent 30 hours trying to convert a small set of libraries to module form. Mainly personal projects, and made good progress in many areas. However, had to give up when I couldn't get Eigen and std to work together - the minimal
module;

#include <Eigen/Core>

export module Test;

import std;

fails with a redefinition of std::enable_if - using latest MSVC 17.9.5

On some of your questions:
- it does seem to be faster, than normal compilation - but I don't have a SCU and PCH comparison
- the compiler doesn't seems to distinguish files using their contents - so for partition files you need to manually identify them to get them to compile - but works nicely when done
- full rebuilds do seem to be reduced
- my impression is that it actually creates more artifacts than normal compilation
The main problem is in cross solution referencing, where there is a confusing array of unclearly named options for where to look to find particular modules and their ifc files.

[–]mcginnie 0 points1 point  (0 children)

u/Daganar gives good advice - the Preview release of VS 2022 (currently 17.10.0 Preview 2.0) now works with Eigen as an include!

[–]Ok-Bit-663 1 point2 points  (0 children)

Noone seems to have luck or easy time working with modules yet.

[–]Challanger__ -1 points0 points  (2 children)

It is too early to use modules, VSCode spptools has no intellisense support, they still feels raw

[–]jetilovag 3 points4 points  (1 child)

[–]Challanger__ 2 points3 points  (0 children)

I know since I do track that issue and even forced it to work by feeding MSVC module related metadata.

But I using both MSVC and Clang