Loïc Joly
unread,Sep 10, 2018, 6:10:10 PM9/10/18Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Evolution Working Group mailing list, mod...@isocpp.org
I've been reading the merged proposal, and I have a question.
Assume I have some code not yet fully migrated to modules, but that
makes use of modules. It can look that way:
// header1.h
#pragma once
#include "other.h"
import std.code;
void g(std::string s);
Now, if I want to use this code from a module, I have two options:
*Option 1**: Legacy header unit*
If I do:
export module mainModule;
import "header1.h"
Then a module is generated out of header1.h, 10.7.3§4 tells "Within a
legacy header unit, certain
semantic restrictions are relaxed:
— A module-import-declaration may appear, and is considered to be exported."
Does it means that this declaration may appear /anywhere/, including in
places where it would not be normally allowed?
*Option 2**: Global module*
module;
#include "header1.h"
export module mainModule;
// ...
If I do so, the preprocessed code will contain an import directive
outside of mainModule preamble, and the code is incorrect (10.7.3§1 In a
module unit, a module-import-declaration shall appear only within the
preamble.).
Do I miss something?
I not, I find this difference of behaviour between the global module
fragment and a legacy header unit disturbing.
---
Loïc