Alex Rivera | Logout

C++ Modules - why were they removed from C++0x? Will they be back later on?

Asked 2010-08-29T19:03:46.417
114

I just discovered this old C++0x draft about modules in C++0x.

The idea was to get out of the current .h/.cpp system by writing only .cpp files which would then generate module files during compilation, which would then in turn be used by the other .cpp files.

This looks like a really great feature.

But my question is: why did they remove it from C++0x? Was it because of too many technical difficulties? Lack of time? And do you think they will consider working on it for an ulterior version of C++?

Edit
Report

2 Answers

32

Clang is the first compiler to start working on modules even before the standardization is complete. There is not much of a documentation yet, but example code could be found here:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/

Some comments from Douglas Gregor (the developer implementing them):
http://clang-developers.42468.n3.nabble.com/C-modules-td3619936.html

In theory, you can define a bunch of helper macros like begin_module, end_module, import_module to shield yourself from any likely changes to the syntax that will come in the future.

EDIT 1:
Douglas Gregor has released a presentation about his implementation:
http://llvm.org/devmtg/2012-11/Gregor-Modules.pdf?=submit

EDIT 2:
The module support in clang have been documented here:
http://clang.llvm.org/docs/Modules.html

EDIT 3:
Modules are now supported in Microsoft's C++ compiler as well: http://blogs.msdn.com/b/vcblog/archive/2015/12/03/c-modules-in-vs-2015-update-1.aspx

answered 2012-03-03T16:28:18.220
-42
  1. Because it is very big conceptual change.
  2. There is no real need of it as separation of the sources to h/cpp does the job
  3. Because C++ does not define how actual "modules" libraries are build. It leaves it to compiler developer and to linker.
  4. "Modules" are sometimes quite platform dependent, for example DLLs quite different from shared objects. So it is not so trivial to merge between these concepts.
answered 2010-08-29T19:10:50.193

Your Answer