[cfe-dev] Modules TS: various problems
Richard Smith via cfe-dev
cfe-dev at lists.llvm.org
Tue Jun 20 11:48:44 PDT 2017
On 20 June 2017 at 05:29, Boris Kolpackov <boris at codesynthesis.com> wrote:
> Boris Kolpackov <boris at codesynthesis.com> writes:
>
> > So, theoretically, I should be able to replace my '#include <string>'
> > with something like 'import std.core' provided I build an appropriate
> > .pcm?
>
> Actually, nothing prevents me from defining my own modules-ts std.core
> module, even if I am using libstdc++:
>
> // file: std-core.mxx -*- C++ -*-
> export module std.core;
>
> #include <string>
> #include <iostream> // For compatibility with VC.
>
> I was then able to replace '#include <string>' with 'import std.core'
> and everything works except for one little niggle: for some reason
> Clang insists that I import in the module's purview:
>
> // file: hello.mxx -*- C++ -*-
> export module hello;
>
> import std.core;
>
> export namespace hello
> {
> void
> say (const std::string& name);
> }
>
> If I move import before the exporting module declaration:
>
> // file: hello.mxx -*- C++ -*-
> import std.core;
>
> export module hello;
>
> export namespace hello
> {
> void
> say (const std::string& name); // line 9
> }
>
> Then I get this error:
>
> hello.mxx:9:14: error: declaration of 'std' must be imported from module
> 'std.core' before it is required say (const std::string& name);
> /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../
> include/c++/6.2.0/iostream:42:11: note: previous declaration is here
> namespace std _GLIBCXX_VISIBILITY(default)
>
> VC is happy with either placement and my reading of the spec suggests
> that it shouldn't matter (unlike #include). Or am I missing something
> here?
This is another "implementation not finished yet" issue. What's happening
here is that "export module hello;" enters a new module scope, and that new
module scope does not (yet) inherit the set of imported modules from the
global module scope.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170620/04b53468/attachment.html>
More information about the cfe-dev
mailing list