C++ Logo

sg15

Advanced search

Re: [SG15] [isocpp-modules] Determining identity like #pragma once

From: Bryce Adelstein Lelbach aka wash <brycelelbach_at_[hidden]>
Date: Wed, 10 Jul 2019 15:26:34 +0200
On Wed, Jul 10, 2019 at 2:48 AM Gabriel Dos Reis via SG15
<sg15_at_[hidden]> wrote:
> Also, we should note that import and #include of the same file can lead to unexpected results, so we need both clarifications and recommendations there for users.

Why should this lead to unexpected results?

Suppose I have:

#include <foo>
import <foo>;

http://eel.is/c++draft/cpp.include#7 says "If the header identified by
the header-name denotes an importable header ([module.import]), the
preprocessing directive is instead replaced by the
preprocessing-tokens `import header-name;`"

http://eel.is/c++draft/module.import#5 says "A
module-import-declaration that specifies a header-name H imports a
synthesized header unit ..." and later "H shall identify an importable
header." (I can't tell if this is a requirement on the user or the
implementation - e.g. is this saying that this is ill-formed if H is
not what the implementation considers to be an importable header).

Anyways, in the above example, import <foo>; (if it's well-formed)
means that foo is an importable header. This means that the #include
<foo> is [cpp.include] p7 replaced with an import <foo>;. I don't see
anything unexpected about importing a module a twice?

Am I missing something?

-- 
Bryce Adelstein Lelbach aka wash
CUDA Core C++ Libraries Lead @ NVIDIA
ISO C++ Library Evolution Incubator Chair
ISO C++ Tooling Chair
CppCon and C++Now Program Chair
CUDA Convert and Reformed AVX Junkie
Sleep is for the weak
--

Received on 2019-07-10 08:28:57