{"id":3785,"date":"2020-05-07T22:55:29","date_gmt":"2020-05-07T20:55:29","guid":{"rendered":"https:\/\/mariusbancila.ro\/blog\/?p=3785"},"modified":"2020-05-12T23:23:02","modified_gmt":"2020-05-12T21:23:02","slug":"modules-in-vc-2019-16-5","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/","title":{"rendered":"Modules in VC++ 2019 16.5"},"content":{"rendered":"<p>Modules are one of the bigest changes in C++20 but the compilers&#8217; support for them is a work in progress. The Visual C++ compiler has experimental support for modules that can be enabled by using the <tt>\/experimental:module<\/tt> and <tt>\/std:c++latest<\/tt> switches. In this post, I will walk through the core of the functionality available in Visual Studio 2019 16.5.<\/p>\n<h2>A first example<\/h2>\n<p>A typical hello world application in C++ looks like this:<\/p>\n<pre class=\"lang:c++ decode:true \" >#include &lt;iostream&gt;\r\n\r\nint main()\r\n{\r\n    std::cout &lt;&lt; \"Hello, World!\\n\";\r\n}<\/pre>\n<p>How do we transform this code so that it uses modules? Just replace the <tt>#include<\/tt> preprocessor directive with an <tt>import<\/tt> directive.<\/p>\n<pre class=\"lang:c++ decode:true \" >import std.core;\r\n\r\nint main()\r\n{\r\n    std::cout &lt;&lt; \"Hello, World!\\n\";\r\n}<\/pre>\n<p>The <tt>std.core<\/tt> module provides most of the content of the C++ Standard Library. The library is modularized as follows:<\/p>\n<ul>\n<li><tt>std.regex<\/tt>: the content of header <tt>&lt;regex&gt;<\/tt><\/li>\n<li><tt>std.filesystem<\/tt>: the content of header <tt>&lt;filesystem&gt;<\/tt><\/li>\n<li><tt>std.memory<\/tt>: the content of header <tt>&lt;memory&gt;<\/tt><\/li>\n<li><tt>std.threading<\/tt>: the contents of headers <tt>&lt;atomic&gt;<\/tt>, <tt>&lt;condition_variable&gt;<\/tt>, <tt>&lt;future&gt;<\/tt>, <tt>&lt;mutex&gt;<\/tt>, <tt>&lt;shared_mutex&gt;<\/tt>, <tt>&lt;thread&gt;<\/tt><\/li>\n<li><tt>std.core<\/tt> the rest of the C++ Standard Library<\/li>\n<\/ul>\n<p>To be able to use the modularized version of the Standard Library you must install the component called <strong>C++ Modules for v142 build tools<\/strong> shown in the following image:<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modules1.png\" alt=\"\" width=\"1200\" height=\"687\" class=\"alignnone size-full wp-image-3786\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modules1.png 1200w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modules1-300x172.png 300w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modules1-768x440.png 768w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modules1-700x401.png 700w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p class=\"tip-lite\">\nWhen importing the Standard Library you should build with the <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/reference\/md-mt-ld-use-run-time-library?view=vs-2019\" rel=\"noopener noreferrer\" target=\"_blank\">\/MD<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/reference\/eh-exception-handling-model?view=vs-2019\" rel=\"noopener noreferrer\" target=\"_blank\">\/EHsc<\/a> options.\n<\/p>\n<p>To build the code snippet above, open a Developer Command Prompt from Visual Studio, and execute the following command:<\/p>\n<pre class=\"lang:default decode:true \" >cl \/std:c++latest \/EHsc \/experimental:module \/MD main.cpp<\/pre>\n<p>Now, if you run <strong>main.exe<\/strong>, you get the expected result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modulesout1.png\" alt=\"\" width=\"376\" height=\"90\" class=\"alignnone size-full wp-image-3788\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modulesout1.png 376w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modulesout1-300x72.png 300w\" sizes=\"auto, (max-width: 376px) 100vw, 376px\" \/><\/p>\n<h2>Writing a module<\/h2>\n<p>Instead of just printing a greeting text in <tt>main()<\/tt>, we could get that text from a function. In the following example, this function called <tt>get_greeting_text()<\/tt> is exported from a module called <tt>greetings<\/tt>. This module is defined in an <em>module interface unit<\/em> called <strong>greetings.ixx<\/strong>.<\/p>\n<p class=\"tip-lite\">\nThe <strong>.ixx<\/strong> extension is required by the VC++ compiler for module interface units.\n<\/p>\n<pre class=\"lang:c++ decode:true \" >export module greetings;\r\n\r\nimport std.core;\r\n\r\nexport std::string get_greeting_text()\r\n{\r\n    return \"Hello, World!\";\r\n}<\/pre>\n<p>The <strong>main.cpp<\/strong> file needs to change slightly to import the <tt>greetings<\/tt> module and invoke the <tt>get_greeting_text()<\/tt> function.<\/p>\n<pre class=\"lang:c++ decode:true \" >import std.core;\r\nimport greetings;\r\n\r\nint main()\r\n{\r\n    std::cout &lt;&lt; get_greeting_text() &lt;&lt; '\\n';\r\n}<\/pre>\n<p>Now, you need to build both <strong>greetings.ixx<\/strong> and <strong>main.cpp<\/strong>. The following commands must be executed:<\/p>\n<pre class=\"lang:default decode:true \" >cl \/std:c++latest \/EHsc \/experimental:module \/MD \/c greetings.ixx\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD main.cpp greetings.obj<\/pre>\n<p>Let&#8217;s add more to the <tt>greetings<\/tt> module. In the following snippet, <tt>greeter<\/tt> is a class with an overloaded call operator that, when invoked, returns a random greeting text.<\/p>\n<pre class=\"lang:c++ decode:true \" >\r\nexport module greetings;\r\n\r\nimport std.core;\r\n\r\nexport std::string get_greeting_text()\r\n{\r\n    return \"Hello, World!\";\r\n}\r\n\r\nexport struct greeter\r\n{\r\n   constexpr static const char* hellos[] {\"Hello\", \"Hi\", \"Hey\"};\r\n   std::string operator()()\r\n   {\r\n      return hellos[rand() % 3] + std::string{\", World!\"};\r\n   }\r\n};<\/pre>\n<p>In <strong>main.cpp<\/strong> we will have the following:<\/p>\n<pre class=\"lang:c++ decode:true \" >import std.core;\r\nimport greetings;\r\n\r\nint main()\r\n{   \r\n    std::cout &lt;&lt; get_greeting_text() &lt;&lt; '\\n';\r\n    \r\n    std::cout &lt;&lt; greeter()() &lt;&lt; '\\n';\r\n}<\/pre>\n<p>The commands for compiling this code remain the same. However, each time we execute the program now a different text will be printed to the console.<\/p>\n<h2>Composing a module from partitions<\/h2>\n<p>Modules can be split into partitions. Partitions help to organize the code of a module, especially if the module is large. Partitions are not exported as stand-alone units but as parts of a module interface unit.<\/p>\n<p>To exemplify module partitions, let&#8217;s split the code of the greetings modules into two partitions: one that contains the free functions, called <strong>greetings-func<\/strong> and one that contains the classes, called <strong>greetings-types<\/strong>. These are also available in files with the extension .ixx. Here is how the look:<\/p>\n<p>The content of <strong>greetings-func.ixx<\/strong> is:<\/p>\n<pre class=\"lang:c++ decode:true \" >export module greetings:func;\r\n\r\nexport const char* get_greeting_text()\r\n{\r\n    return \"Hello, World!\";\r\n}<\/pre>\n<p>The content of <strong>greetings-types.ixx<\/strong> is:<\/p>\n<pre class=\"lang:c++ decode:true \" >module;\r\n\r\n#include &lt;cstdlib&gt;\r\n\r\nexport module greetings:types;\r\n\r\nimport std.core;\r\n\r\nexport struct greeter\r\n{\r\n   constexpr static const char* hellos[] {\"Hello\", \"Hi\", \"Hey\"};\r\n   std::string operator()()\r\n   {\r\n      return hellos[rand() % 3] + std::string{\", World!\"};\r\n   }\r\n};<\/pre>\n<p>The syntax for exporting a module partitions is <tt>export module &lt;module-name&gt;:&lt;partition-name&gt;<\/tt>. The rest is no different than regular module interface units.<\/p>\n<p>These two partitions are then imported and re-exported from the module interface unit, <strong>greetings.ixx<\/strong> as follows:<\/p>\n<pre class=\"lang:c++ decode:true \" >export module greetings;\r\n\r\nexport import :func;\r\nexport import :types;<\/pre>\n<p>The syntax for exporting a partition is <tt>export import :&lt;partition-name&gt;<\/tt>. Of course, apart from these directives, the module interface unit may contain any other exports.<\/p>\n<p>The content of <strong>main.cpp<\/strong> does not change. However, we need to change the commands we use to build the code, as follows:<\/p>\n<pre class=\"lang:default decode:true \" >cl \/std:c++latest \/EHsc \/experimental:module \/MD \/c greetings-func.ixx\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD \/c greetings-types.ixx\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD \/c greetings.ixx\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD main.cpp greetings-func.obj greetings-types.obj<\/pre>\n<p>Building this way is possible because we leveraged a naming scheme supported by the VC++ compiler for module partition units. That is <strong>&lt;module-name&gt;-&lt;partition-name&gt;.ixx<\/strong>. If you do not follow this scheme, then you need to use the <tt>\/module:reference<\/tt> switch to specify the module partition interfaces.<\/p>\n<h2>Internal partitions<\/h2>\n<p>A partition does not have to be an interface unit. It could contain code that is not supposed to be exported from the module. Such a partition is called an internal partition and must be put in a file with the extension <strong>.cpp<\/strong>. <\/p>\n<p>To see how these work, let&#8217;s modify the previous example where we used the <tt>rand()<\/tt> function in the <tt>greeter<\/tt> class. We will remove the details of generating a new integer to another function called <tt>next_rand()<\/tt> available in an internal partition called <strong>greetings:details<\/strong>. This function is not exported from the <strong>greetings<\/strong> module. The content of <strong>greetings-details.cpp<\/strong> is shown in the following snippet:<\/p>\n<pre class=\"lang:c++ decode:true \" >module;\r\n\r\n#include &lt;cstdlib&gt;\r\n\r\nmodule greetings:details;\r\n\r\nint next_rand()\r\n{\r\n    return rand();\r\n}<\/pre>\n<p>We need to modify the code in the <strong>greetings:types<\/strong> partition as follows (notice the <tt>import :details<\/tt> directive):<\/p>\n<pre class=\"lang:c++ decode:true \" >export module greetings:types;\r\n\r\nimport std.core;\r\nimport :details;\r\n\r\nexport struct greeter\r\n{\r\n   constexpr static const char* hellos[] {\"Hello\", \"Hi\", \"Hey\"};\r\n   std::string operator()()\r\n   {\r\n      return hellos[next_rand() % 3] + std::string{\", World!\"};\r\n   }\r\n};<\/pre>\n<p>Nothing else needs to change except for the build commands. We have a new file to build, <strong>greetings-details.cpp<\/strong> and it requires a new compiler switch, <tt>\/module:internalPartition<\/tt> to indicate that the file that is compiled is an internal partion of a module.<\/p>\n<pre class=\"lang:default decode:true \" >cl \/std:c++latest \/EHsc \/experimental:module \/MD \/c greetings-func.ixx\r\ncl \/std:c++latest \/EHsc \/experimental:module \/module:internalPartition \/MD \/c greetings-details.cpp\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD \/c greetings-types.ixx\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD \/c greetings.ixx\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD main.cpp greetings-func.obj greetings-types.obj greetings-details.obj<\/pre>\n<p>Now, we can change the implementation details of the <tt>next_rand()<\/tt> function without affecting the module interface.<\/p>\n<pre class=\"lang:c++ decode:true \" >module greetings:details;\r\n\r\nimport std.core;\r\n\r\nint next_rand()\r\n{\r\n    static std::random_device rd{};\r\n    static std::mt19937 eng{rd()};\r\n    static std::uniform_int_distribution&lt;&gt; uid {0, 1000};\r\n    return uid(eng);\r\n}<\/pre>\n<p>To build the program we only need to run the following commands:<\/p>\n<pre class=\"lang:default decode:true \" >cl \/std:c++latest \/EHsc \/experimental:module \/module:internalPartition \/MD \/c greetings-details.cpp\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD main.cpp greetings-func.obj greetings-types.obj greetings-details.obj<\/pre>\n<h2>Importing header units<\/h2>\n<p>What if the <tt>get_greeting_text()<\/tt> was already available in a header file, which perhaps you cannot modularize, maybe because you do not own the code? Modules support the importing of a special translation unit called <em>header unit<\/em>. <\/p>\n<p>Suppose the header, called <strong>greetings.h<\/strong> looks like this:<\/p>\n<pre class=\"lang:c++ decode:true \" >#pragma once\r\n\r\ninline const char* get_greeting_text()\r\n{\r\n    return \"Hello, World!\";\r\n}<\/pre>\n<p>We can import this using the same <tt>import<\/tt> directive, as shown in the below snippet:<\/p>\n<pre class=\"lang:c++ decode:true \" >import std.core;\r\nimport \"greetings.h\";\r\n\r\nint main()\r\n{   \r\n    std::cout &lt;&lt; get_greeting_text() &lt;&lt; '\\n';\r\n}\r\n<\/pre>\n<p>To build the program, this time, the build commands must be the following:<\/p>\n<pre class=\"lang:default decode:true \" >cl \/std:c++latest \/EHsc \/experimental:module \/MD \/module:exportHeader greetings.h \/Fogreetings.h.obj\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD \/module:reference greetings.h:greetings.h.ifc main.cpp greetings.h.obj<\/pre>\n<p>There are several compiler switches used here:<\/p>\n<ul>\n<li><tt>\/module:exportHeader<\/tt> specifies that a header will be exported as a header unit. It requires the path to the header.<\/li>\n<li><tt>\/Fo<\/tt> that specifies the name of a object file. Without this, the compiler only generates and .ifc file.<\/li>\n<li><tt>\/module:reference<\/tt> that has an argument of the form <tt>&lt;path-to-header&gt;:&lt;path-to-ifc&gt;<\/tt>.<\/li>\n<\/ul>\n<p class=\"tip-icon-lite\">The .ifc file is a binary file generated by the compiler when exporting a module interface. It contains metadata about the module interface and is modeled based on the <a href=\"http:\/\/www.stroustrup.com\/gdr-bs-macis09.pdf\" rel=\"noopener noreferrer\" target=\"_blank\">Internal Program Representation<\/a> (IPR) for C++, developed by Gabriel Dos Reis and Bjarne Stroustrup. The IFC is the <em>binary module interface<\/em> (BMI), which is the term found in documentation.<\/p>\n<h2>Exporting templates<\/h2>\n<p>Templates can also be exported from a module. Let&#8217;s look at an example. The following module is available in a file called <strong>foo.ixx<\/strong>:<\/p>\n<pre class=\"lang:c++ decode:true \" >export module foo;\r\n\r\nexport template &lt;typename T&gt;\r\nstruct foo\r\n{\r\n    T value;\r\n    \r\n    foo(T const v):value(v){}\r\n};\r\n\r\nexport template &lt;typename T&gt;\r\nfoo&lt;T&gt; make_foo(T const value)\r\n{\r\n    return foo<T>(value);\r\n}<\/pre>\n<p>In this snippet, the module <tt>foo<\/tt> contains a class template also called <tt>foo<\/tt> and function template called <tt>make_foo()<\/tt> that creates an instance of <tt>foo<\/tt>. Notice that the keyword <tt>export<\/tt> is preceding the keyword <tt>template<\/tt>. This module can be imported and its exports used in <strong>main.cpp<\/strong> as follows:<\/p>\n<pre class=\"lang:c++ decode:true \" >import std.core;\r\nimport foo;\r\n\r\nint main()\r\n{   \r\n    auto fi = make_foo(42);\r\n    std::cout &lt;&lt; fi.value &lt;&lt; '\\n';\r\n    \r\n    auto fs = make_foo(std::string(\"modules\"));\r\n    std::cout &lt;&lt; fs.value &lt;&lt; '\\n';\r\n}<\/pre>\n<p>To build this program you must use the following build commands:<\/p>\n<pre class=\"lang:c++ decode:true \" >cl \/std:c++latest \/EHsc \/experimental:module \/MD \/c foo.ixx\r\ncl \/std:c++latest \/EHsc \/experimental:module \/MD main.cpp foo.obj<\/pre>\n<p>If you run this, it will print <em>42<\/em> and <em>modules<\/em> to the console.<\/p>\n<h2>See also<\/h2>\n<p>To learn more about modules in Visual C++ you can read the following:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/cpp\/modules-cpp?view=vs-2019\" rel=\"noopener noreferrer\" target=\"_blank\">Overview of modules in C++<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/c-modules-conformance-improvements-with-msvc-in-visual-studio-2019-16-5\/\" rel=\"noopener noreferrer\" target=\"_blank\">C++ Modules conformance improvements with MSVC in Visual Studio 2019 16.5<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/cpp-modules-in-visual-studio-2017\/\" rel=\"noopener noreferrer\" target=\"_blank\">Using C++ Modules in Visual Studio 2017<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Modules are one of the bigest changes in C++20 but the compilers&#8217; support for them is a work in progress. The Visual C++ compiler has experimental support for modules that can be enabled by using the \/experimental:module and \/std:c++latest switches. In this post, I will walk through the core of the functionality available in Visual &#8230; <a title=\"Modules in VC++ 2019 16.5\" class=\"read-more\" href=\"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/\" aria-label=\"Read more about Modules in VC++ 2019 16.5\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[7],"tags":[451,543,477],"class_list":["post-3785","post","type-post","status-publish","format-standard","hentry","category-c","tag-c","tag-c20","tag-modules"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"A walk-through the support for C++20 modules in Visual Studio 2019 16.5.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"c++,c++20,modules\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Modules in VC++ 2019 16.5\" \/>\n\t\t<meta property=\"og:description\" content=\"A walk-through the support for C++20 modules in Visual Studio 2019 16.5.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-05-07T20:55:29+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-05-12T21:23:02+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Modules in VC++ 2019 16.5\" \/>\n\t\t<meta name=\"twitter:description\" content=\"A walk-through the support for C++20 modules in Visual Studio 2019 16.5.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#article\",\"name\":\"Modules in VC++ 2019 16.5\",\"headline\":\"Modules in VC++ 2019 16.5\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/05\\\/modules1.png\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#articleImage\",\"width\":1200,\"height\":687},\"datePublished\":\"2020-05-07T22:55:29+02:00\",\"dateModified\":\"2020-05-12T23:23:02+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":2,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#webpage\"},\"articleSection\":\"C++, C++, c++20, modules\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"position\":4,\"name\":\"C++\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#listItem\",\"name\":\"Modules in VC++ 2019 16.5\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#listItem\",\"position\":5,\"name\":\"Modules in VC++ 2019 16.5\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/\",\"name\":\"Modules in VC++ 2019 16.5\",\"description\":\"A walk-through the support for C++20 modules in Visual Studio 2019 16.5.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2020\\\/05\\\/07\\\/modules-in-vc-2019-16-5\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2020-05-07T22:55:29+02:00\",\"dateModified\":\"2020-05-12T23:23:02+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Modules in VC++ 2019 16.5","description":"A walk-through the support for C++20 modules in Visual Studio 2019 16.5.","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/","robots":"max-image-preview:large","keywords":"c++,c++20,modules","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#article","name":"Modules in VC++ 2019 16.5","headline":"Modules in VC++ 2019 16.5","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2020\/05\/modules1.png","@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#articleImage","width":1200,"height":687},"datePublished":"2020-05-07T22:55:29+02:00","dateModified":"2020-05-12T23:23:02+02:00","inLanguage":"en-US","commentCount":2,"mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#webpage"},"articleSection":"C++, C++, c++20, modules"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","position":4,"name":"C++","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#listItem","name":"Modules in VC++ 2019 16.5"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#listItem","position":5,"name":"Modules in VC++ 2019 16.5","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/","name":"Modules in VC++ 2019 16.5","description":"A walk-through the support for C++20 modules in Visual Studio 2019 16.5.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2020-05-07T22:55:29+02:00","dateModified":"2020-05-12T23:23:02+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"Modules in VC++ 2019 16.5","og:description":"A walk-through the support for C++20 modules in Visual Studio 2019 16.5.","og:url":"https:\/\/mariusbancila.ro\/blog\/2020\/05\/07\/modules-in-vc-2019-16-5\/","article:published_time":"2020-05-07T20:55:29+00:00","article:modified_time":"2020-05-12T21:23:02+00:00","twitter:card":"summary","twitter:title":"Modules in VC++ 2019 16.5","twitter:description":"A walk-through the support for C++20 modules in Visual Studio 2019 16.5."},"aioseo_meta_data":{"post_id":"3785","title":null,"description":"A walk-through the support for C++20 modules in Visual Studio 2019 16.5.","keywords":[{"label":"C++","value":"C++"},{"label":"C++20","value":"C++20"},{"label":"modules","value":"modules"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-18 21:02:54","updated":"2025-12-12 07:54:48","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":2,"uagb_excerpt":"Modules are one of the bigest changes in C++20 but the compilers&#8217; support for them is a work in progress. The Visual C++ compiler has experimental support for modules that can be enabled by using the \/experimental:module and \/std:c++latest switches. In this post, I will walk through the core of the functionality available in Visual&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">c++20<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">modules<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">c++20<\/span>","<span class=\"advgb-post-tax-term\">modules<\/span>"]}},"comment_count":"2","relative_dates":{"created":"Posted 6 years ago","modified":"Updated 6 years ago"},"absolute_dates":{"created":"Posted on May 7, 2020","modified":"Updated on May 12, 2020"},"absolute_dates_time":{"created":"Posted on May 7, 2020 10:55 pm","modified":"Updated on May 12, 2020 11:23 pm"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-Z3","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/3785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=3785"}],"version-history":[{"count":43,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/3785\/revisions"}],"predecessor-version":[{"id":3839,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/3785\/revisions\/3839"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=3785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=3785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=3785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}