[cfe-dev] Modules TS and templates

Boris Kolpackov via cfe-dev cfe-dev at lists.llvm.org
Wed Jul 5 11:06:30 PDT 2017


Emily Maier writes:

> Am I missing something? If I add an "import bar;" statement to main.cppm 
> it compiles and works fine. Shouldn't Clang be able to walk the imports 
> and instantiate the bar template it needs?

My guess would be this is not implemented yet. If you replace bar with
an inline function (which doesn't change anything from the module name
visibility POV), then it links:

export inline void bar(int index) {
  std::cout << index << " from bar!" << std::endl;
}


> export module main;
>
> import foo;
>
> int main(int argc, char** argv) {
> [...]

So you've put main() into a module's purview. Since it is not exported,
it will have module linkage which means the symbol will most likely
end up decorated and not what the runtime expects. It works with Clang
because currently it exports everything (according to Richard).

Just me test-driving the newly-acquired C++ modules knowledge ;-).

Boris



More information about the cfe-dev mailing list