C++ Logo


Advanced search

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

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Wed, 10 Jul 2019 00:48:06 +0000
I agree.

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.

— Gaby

On Jul 9, 2019, at 5:07 PM, Richard Smith via Modules <modules_at_[hidden]<mailto:modules_at_[hidden]>> wrote:

On Tue, Jul 9, 2019 at 6:23 AM Ben Craig via SG15 <sg15_at_[hidden]<mailto:sg15_at_[hidden]>> wrote:
tl;dr: Should the Tooling TR provide guidance on how to determine header unit identity?

The compiler is only supposed to import / include a header unit once, no matter how many times it sees the directive. This is similar to the popular vendor extension “#pragma once”. Like “#pragma once”, the compiler needs to be able to tell when a header unit is the same. This is tricky. In a single TU, #include “foo.h” could refer to two different header units. #include “bar.h”, import <bar.h>, and #include <dir/bar.h> could all refer to the same header unit.

The different compilers use different approached for determining identity. Some use the file path (this breaks with hard links). Some use the file identity / inode (network shares can break this). I believe some even use the file contents (seems slow?). Should the Tooling TR recommend an approach for identity comparison, or are we happy leaving this up to the implementers?

I think it would make sense for the TR to include a recommendation (or rather, one per platform).
Modules mailing list
Subscription: https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fmodules&amp;data=02%7C01%7Cgdr%40microsoft.com%7Cd98ab98aaaff488fe54e08d704ca9cf5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636983140570225303&amp;sdata=nPaYMpDSg2DEfQ8mhxdW5xCZ2E2vI1ZIgLULGhY0dyM%3D&amp;reserved=0
Link to this post: https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.isocpp.org%2Fmodules%2F2019%2F07%2F0474.php&amp;data=02%7C01%7Cgdr%40microsoft.com%7Cd98ab98aaaff488fe54e08d704ca9cf5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636983140570225303&amp;sdata=%2BxoIYHbg3l13Hbdi0UvHK04Op0hOLqgRH7w8hEORRqo%3D&amp;reserved=0

Received on 2019-07-09 19:50:01