Support for C ++ modules in Visual Studio 2015 Update 1

  • Tutorial
At the CppCon conference , which is taking place right now, the Visual C ++ compiler development team said that in the next update (Visual Studio 2015 Update 1), an experimental feature from the new (not yet approved) C ++ standard will be added to the Microsoft C ++ compiler - module support!

For those who do not know what the epoch of this event is: it just so happened that the mechanism for using components in C ++ programs was invented some 35 years ago. It cannot be called convenient: if you want to create a library, you need to make a header file and distribute with it either code or a compiled version of the library. This raises a bunch of problems:
  • The header file and the library are separate files, one of them may be lost, or they may accidentally be out of sync.
  • The header file is included in the code by the #include preprocessor directive, which, firstly, slows down compilation, and secondly adds the effect of everything that is written in the header files to each other and to the final code. There are frequent cases when the header files need to be included in a certain order or to define some macros so that the code is assembled normally.

As a result, there are no concepts of “assemblies” or “packages” in the C ++ infrastructure, and, unlike C # or Python, where installing components is trivial, in C ++ the connection of each new library may carry its own surprises. The proposed module mechanism in C ++ is designed to remove this problem, abandon the #include preprocessor directive and refer to components as some entity, consisting of code and metadata, integrated and easily connected. As a result, we can soon get a significant acceleration of the introduction of new components in the project, the emergence of full-fledged package managers, the installation of a new library will be reduced to the execution of a single line or several mouse clicks. Is it not happiness!

Under the cut will be examples of use and links to documentation.

The video of the presentation is not yet available on the conference channel, so all we have is a few photos from Twitter, and links to the proposed draft standard modules and its implementation in Visual C ++ and Clang.

Also popular now: