add tag
GreenDragon
C++20 brought us a modules, and while compilers support of this language feature is weak, some already provide at least partial support. 

VS2019 claim that has experimental support of modules. But how make it works?

From microft's docs [Overview of modules in C++](https://docs.microsoft.com/en-us/cpp/cpp/modules-cpp?view=vs-2019) I know that I need file with .ixx extension, let's call it Foo.ixx:
  
    export module Foo;
    
    namespace Foo
    {
       export int f() 
       {
          return 42;
       }
    }
    
 and test.cpp:

    import Foo;
    import std.core;
    
    int main()
    {
        std::cout << "The result of f() is " << Foo::f() << '\n';
    }

How can I build this example from Visual Studio 2019 Developer Command Prompt?
Top Answer
JHBonarius
As described [here](https://devblogs.microsoft.com/cppblog/c-modules-conformance-improvements-with-msvc-in-visual-studio-2019-16-5/), you need to compile with two options:
* std:c++latest
* experimental:module

I.e.

```
cl /experimental:module /std:c++latest /c Foo.ixx
cl /experimental:module /std:c++latest test.cpp Foo.obj

```

Note that for `import std.core;` to work you need to have the library part of the C++ modules feature installed (via VS setup)

Also note that the VS gui doesn't properly seem to recognize the `.ixx` extention. You at least need to set the `item type` to `C/C++ compiler` under configuration properties.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.