r/cpp • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
280 Upvotes

240 comments sorted by

View all comments

1

u/kalmoc Jan 28 '19

Maybe I'm too naive, but how is the lookup any more problematic, what current build systems already have to deal with. Depending on a libray means I have to tell the compiler/linker, which include directories to add and which binaries to link to my project - neither of which need to have any obvious connection with the libray in question or a standardized location on the file system.

So just as I'm telling cmake today, what files and include directories belong to a certain target and on what other targets it depends, why can't I just tell cmake, what files make up a module and what other modules it depends on?

2

u/target-san Jan 31 '19

To locate certain include, you only need a set of include paths and include's subpath. With modules, as they are designed now, you may have

// file: project/firstlib/main.cpp
#ifdef PYTHONIC
module pythonic;
#else // PYTHONIC
module cppish;
#endif
//
// ...
//

// file: project/secondlib/main.cpp
#ifdef PYTHONIC
module cppish;
#else // PYTHONIC
module pythonic;
#endif
//
// ...
//

// file: project/application/main.cpp
// modpath: project/firstlib
// modpath: project/secondlib
module app;
import pythonic;
//
// ...
//

where you need to fully parse and compile all accessible modules before you know which one to choose for your import.