220 29134 <CAGg_6+NpwATgqV8hZPQ3TPkHt67fDi2=iRpUJwrt-Vn1dG=XOw@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nevin Liber <nevin@eviloverlord.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: pragma once
Date: Wed, 26 Oct 2016 14:38:33 -0500
Lines: 118
Approved: news@gmane.org
Message-ID: <CAGg_6+NpwATgqV8hZPQ3TPkHt67fDi2=iRpUJwrt-Vn1dG=XOw@mail.gmail.com>
References: <CAGz9X0c=CNLVEGgJ7=GJ2W+7fsvN7h+tbiFyf5Cx3aab0Xb=rQ@mail.gmail.com>
 <ca5a8fe4-6a28-4552-89e8-35d2a8a9980d@isocpp.org> <5810C33B.9060503@gmail.com>
 <2908d573-f002-4b58-b0da-18420a816c16@isocpp.org> <bdd21365-4aab-9463-a384-84afaec533b8@gmail.com>
 <30401812-7fc8-481a-abaa-7868d133d778@isocpp.org> <5810FA03.8000201@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11403282acc87d053fc9c748
X-Trace: blaine.gmane.org 1477510777 27977 195.159.176.226 (26 Oct 2016 19:39:37 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 26 Oct 2016 19:39:37 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCE35H5S6IDBBY4MYTAAKGQE4NOKBWI@isocpp.org Wed Oct 26 21:39:33 2016
Return-path: <std-proposals+bncBCE35H5S6IDBBY4MYTAAKGQE4NOKBWI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f71.google.com ([209.85.218.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCE35H5S6IDBBY4MYTAAKGQE4NOKBWI@isocpp.org>)
	id 1bzU2b-0004pX-PZ
	for gclcip-std-proposals@m.gmane.org; Wed, 26 Oct 2016 21:39:13 +0200
Original-Received: by mail-oi0-f71.google.com with SMTP id p136sf9981118oic.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 26 Oct 2016 12:39:16 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
         :date:message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=laHnILOvrk0WI760sOTFwiAZNMMoIx7s4GVA2nxuniw=;
        b=HKV7Rb5narXY9KLFUD09fYlqc7RbDHgp6GbNdP59DNg2c56EtAcyNFSM/yvps20PaM
         VCnrJg0oP0/GcC/i/qm9PmdSG4lRUav6FmhgxCOzGVxuhRg8Rr6kl9X5lOk/g8yk6bIW
         FiS6XkqO/0KgzUTJXUCgFMCoGNbHYRVtBCgRC5vkHoksTMllugxfH1ud+It6Ei2WODO6
         DLlFOtXlNYS+Wa3WfhY2LPbbRziVrRIP+j3rfNgJXDM1MrN86BmS74/PYIyYOo5QbAS0
         DPFDcd5xfDN18tyCuLP9FjKCO4m61O4gtCHaBLR6k8HeyK9CssbF/buQJDZPKPAn8/Z+
         5QsQ==
X-Gm-Message-State: ABUngvez2ZwqUgO2n7lZcl4H1yHv/2bJ96/QZHY4XvyDCTQnQSyKF+EGMEubsknjTeHl5w==
X-Received: by 10.157.2.137 with SMTP id 9mr377151otl.43.1477510755914;
        Wed, 26 Oct 2016 12:39:15 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.22.172 with SMTP id c41ls336916ote.42.gmail; Wed, 26 Oct
 2016 12:39:15 -0700 (PDT)
X-Received: by 10.202.199.66 with SMTP id x63mr3281699oif.25.1477510755118;
        Wed, 26 Oct 2016 12:39:15 -0700 (PDT)
Original-Received: from mail-oi0-x22d.google.com (mail-oi0-x22d.google.com. [2607:f8b0:4003:c06::22d])
        by mx.google.com with ESMTPS id r189si2675495oia.215.2016.10.26.12.39.14
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 26 Oct 2016 12:39:14 -0700 (PDT)
Received-SPF: pass (google.com: domain of nliber@gmail.com designates 2607:f8b0:4003:c06::22d as permitted sender) client-ip=2607:f8b0:4003:c06::22d;
Original-Received: by mail-oi0-x22d.google.com with SMTP id y2so7852205oie.0
        for <std-proposals@isocpp.org>; Wed, 26 Oct 2016 12:39:14 -0700 (PDT)
X-Received: by 10.202.106.65 with SMTP id f62mr3284245oic.68.1477510754517;
 Wed, 26 Oct 2016 12:39:14 -0700 (PDT)
Original-Sender: nliber@gmail.com
Original-Received: by 10.157.50.201 with HTTP; Wed, 26 Oct 2016 12:38:33 -0700 (PDT)
In-Reply-To: <5810FA03.8000201@gmail.com>
X-Original-Sender: nevin@eviloverlord.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of nliber@gmail.com
 designates 2607:f8b0:4003:c06::22d as permitted sender) smtp.mailfrom=nliber@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:29134
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29134>

--001a11403282acc87d053fc9c748
Content-Type: text/plain; charset=UTF-8

On Wed, Oct 26, 2016 at 1:46 PM, Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:

> Apparently (disclaimer: I am repeating statements made elsewhere, though
> I think I can guess the underlying reasoning) this is harder than you
> think. I suspect that computing a hash of the file is the only reliable
> method. (We'll assume the contents are at least constant during
> compilation, since if they aren't, you're probably doomed no matter what.)
>

Include guards are about "do these files have the same contents"?

#pragma once is about "do these names refer to the same file (roughly, bits
from the same spot on a disk)", which is a question compilers generally
punt on by just asking the OS for the answer.

They are different questions.

Let's say I have these files:

a/z.h
b/y.h (hard link to a/z.h)
c/x.h (symlink to a/z.h)
d/w.h (copy of a/z.h)
e/z.h (e/ is the same filesystem as a/ mounted at a different location)

Include guards would say that all of the files have the same contents.

I would expect that #pragma once would consider a/z.h, b/y.h and c/x.h to
be the same file, and d/z.h to be different from those three and e/z.h to
be different from those four.  Another possibility is that a/z.h,b/y.h,
c/x.h are considered different files because they have different base names.

We *could* make a #once feature give the same answer as include guards, but
as Matthew pointed out, that would requiring hashing (fingerprinting) files
to determine if two files have the same contents when the OS cannot
determine if two filenames either refer to the same file or have different
content (differing file sizes implies different content, for example).  The
advantage of #once over include guards is that include guards can be
mistaken (using the same guard in two unrelated files).

I wonder how much fingerprint hashing would slow down compilation?
-- 
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  +1-847-691-1404

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BNpwATgqV8hZPQ3TPkHt67fDi2%3DiRpUJwrt-Vn1dG%3DXOw%40mail.gmail.com.

--001a11403282acc87d053fc9c748
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra">On Wed, Oct 26, 2016 at 1:46 PM=
, Matthew Woehlke <span dir=3D"ltr">&lt;<a href=3D"mailto:mwoehlke.floss@gm=
ail.com" target=3D"_blank">mwoehlke.floss@gmail.com</a>&gt;</span> wrote:<b=
r><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=3D":162=
" class=3D"a3s aXjCH m1580250a84765082">Apparently (disclaimer: I am repeat=
ing statements made elsewhere, though<br>
I think I can guess the underlying reasoning) this is harder than you<br>
think. I suspect that computing a hash of the file is the only reliable<br>
method. (We&#39;ll assume the contents are at least constant during<br>
compilation, since if they aren&#39;t, you&#39;re probably doomed no matter=
 what.)<br></div></blockquote></div><br>Include guards are about &quot;do t=
hese files have the same contents&quot;?</div><div class=3D"gmail_extra"><b=
r></div><div class=3D"gmail_extra">#pragma once is about &quot;do these nam=
es refer to the same file (roughly, bits from the same spot on a disk)&quot=
;, which is a question compilers generally punt on by just asking the OS fo=
r the answer.</div><div class=3D"gmail_extra"><br></div><div class=3D"gmail=
_extra">They are different questions.<br><br clear=3D"all"><div>Let&#39;s s=
ay I have these files:</div><div><br></div><div>a/z.h</div><div>b/y.h (hard=
 link to a/z.h)</div><div>c/x.h (symlink to a/z.h)</div><div>d/w.h (copy of=
 a/z.h)</div><div>e/z.h (e/ is the same filesystem as a/ mounted at a diffe=
rent location)</div><div><br></div><div>Include guards would say that all o=
f the files have the same contents.</div><div><br></div><div>I would expect=
 that #pragma once would consider a/z.h, b/y.h and c/x.h to be the same fil=
e, and d/z.h to be different from those three and e/z.h to be different fro=
m those four.=C2=A0 Another possibility is that a/z.h,b/y.h, c/x.h are cons=
idered different files because they have different base names.</div><div><b=
r></div><div>We <i>could</i> make a #once feature give the same answer as i=
nclude guards, but as Matthew pointed out, that would requiring hashing (fi=
ngerprinting) files to determine if two files have the same contents when t=
he OS cannot determine if two filenames either refer to the same file or ha=
ve different content (differing file sizes implies different content, for e=
xample).=C2=A0 The advantage of #once over include guards is that include g=
uards can be mistaken (using the same guard in two unrelated files).</div><=
div><br></div><div>I wonder how much fingerprint hashing would slow down co=
mpilation?</div>-- <br><div class=3D"gmail_signature" data-smartmail=3D"gma=
il_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevin &quot=
;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlord.com"=
 target=3D"_blank">nevin@eviloverlord.com</a>&gt; =C2=A0+1-847-691-1404</di=
v></div></div></div></div>
</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BNpwATgqV8hZPQ3TPkHt67fDi2%3D=
iRpUJwrt-Vn1dG%3DXOw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BNp=
wATgqV8hZPQ3TPkHt67fDi2%3DiRpUJwrt-Vn1dG%3DXOw%40mail.gmail.com</a>.<br />

--001a11403282acc87d053fc9c748--

.
