<div dir="auto">Performance should be fine if using a content definition. An implementation can do inode/path checks against files it already knows of, as a fast path. The first time a file is #included it’s just a hash+table lookup to decide whether to continue.</div><div dir="auto"><br></div><div dir="auto">Regarding the filesystem definition vs content definition question, while I think a content-based definition is robust I can see there is FUD about it and also an argument about current practice being a filesystem-based definition. It may just be best to approach this as filesystem uniqueness to the implementation’s ability, with a requirement that symbolic links/hard links are handled. This doesn’t cover the case of multiple mount points, but we’ve discussed that that’s impossible with #pragma once without using contents instead.</div><div dir="auto"><br></div><div dir="auto">Jeremy</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 29, 2024 at 13:06 Tom Honermann &lt;<a href="mailto:tom@honermann.net">tom@honermann.net</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><u></u>

  
    
  
  <div>
    <div>On 8/28/24 12:32 AM, Jeremy Rifkin via
      Std-Proposals wrote:<br>
    </div>
    <blockquote type="cite">
      <blockquote type="cite">
        <pre style="font-family:monospace">Another question is whether the comparison should be post translation
phase 1.
</pre>
      </blockquote>
      <pre style="font-family:monospace">I gave this some thought while drafting the proposal. I think it comes
down to whether the intent is single inclusion of files or single
inclusion of contents.</pre>
    </blockquote>
    <p>Indeed. The proposal currently favors the &quot;same contents&quot;
      approach and offers the following wording.</p>
    <blockquote>
      <p>A preprocessing directive of the form<br>
          <font face="monospace" style="font-family:monospace;color:rgb(0,0,0)"># pragma once new-line</font><br>
        shall cause no subsequent <font face="monospace" style="font-family:monospace;color:rgb(0,0,0)">#include</font>
        directives to perform replacement for a file with <b>text
          contents identical to this file</b>. <br>
      </p>
    </blockquote>
    <p>The wording will have to define what it means for contents to be
      identical. Options include:</p>
    <ul>
      <li>The files must be byte-for-byte identical. This makes source
        file encoding observable (which I would be strongly against).<br>
      </li>
      <li>The files must encode the same character sequence post
        translation phase 1. This makes comparisons potentially
        expensive.<br>
      </li>
    </ul>
    <p>Note that the &quot;same contents&quot; approach obligates an
      implementation to consider every previously encountered file for
      every <font face="monospace" style="font-family:monospace;color:rgb(0,0,0)">#include</font> directive. An inode
      based optimization can help to determine if a file was previously
      encountered based on identity, but it doesn&#39;t help to reduce the
      costs when a file that was not previously seen is encountered.</p></div><div><p><br>
    </p>
    <p>Tom.<br>
    </p>
    <blockquote type="cite">
      <pre style="font-family:monospace">
Jeremy

On Tue, Aug 27, 2024 at 3:39 PM Tom Honermann via Std-Proposals
<a href="mailto:std-proposals@lists.isocpp.org" target="_blank" style="font-family:monospace">&lt;std-proposals@lists.isocpp.org&gt;</a> wrote:
</pre>
      <blockquote type="cite">
        <pre style="font-family:monospace">On 8/27/24 4:10 PM, Thiago Macieira via Std-Proposals wrote:
</pre>
        <blockquote type="cite">
          <pre style="font-family:monospace">On Tuesday 27 August 2024 12:35:17 GMT-7 Andrey Semashev via Std-Proposals
wrote:
</pre>
          <blockquote type="cite">
            <pre style="font-family:monospace">The fact that gcc took the approach to compare file contents I consider
a poor choice, and not an argument to standardize this implementation.
</pre>
          </blockquote>
          <pre style="font-family:monospace">Another question is whether a byte comparison of two files of the same size is
expensive for compilers.

#once ID doesn&#39;t need to compare the entire file.
</pre>
        </blockquote>
        <pre style="font-family:monospace">Another question is whether the comparison should be post translation
phase 1. In other words, whether differently encoded source files that
decode to the same sequence of code points are considered the same file
(e.g., a Windows-1252 version and a UTF-8 version). Standard C++ does
not currently allow source file encoding to be observable but a #pragma
once implementation that only compares bytes would make such differences
observable.

Tom.

--
Std-Proposals mailing list
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank" style="font-family:monospace">Std-Proposals@lists.isocpp.org</a>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" target="_blank" style="font-family:monospace">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a>
</pre>
      </blockquote>
    </blockquote>
  </div>

</blockquote></div></div>

