C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Revising #pragma once

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 23 Sep 2024 09:28:15 +0100
On Mon, Sep 23, 2024 at 9:04 AM Ville Voutilainen wrote:
>
> That's completely irrelevant, the build machine's newline handling can
> be whatever, as the content hash doesn't
> need to be the same on different machines.


I meant something like the following:

Leonardo has his Apple laptop, and he checks out code to
\\192.168.1.62\code\project1.
Donatello has his MS-Windows laptop, and he checks out code to
\\192.168.1.62\code\project2.

So Leonardo and Donatello have all of their code checked out to the
same network drive.

In Donatello's project, he has a source file containing the line:

    #include "../project1/monkey.hpp"

This header file has been checked out by Leonardo with Apple line
endings. But Donatello also has his own copy of "monkey.hpp" in his
own checkout, and one of Donatello's source files looks like this:

    #include "../project1/monkey.hpp"
    #include "common//monkey.hpp"

So the first directive gets the header file with "\r\n" line endings,
and the second directive gets it with "\n" line endings. And so if
we're going to be taking the hash of file contents, I think best to
normalise the line endings first (and also to remove trailing new line
characters).

Taking the hash of file contents might have too great an impact on
compile times though. If compile time weren't an issue though, then I
think taking the hash of file contents would be the optimal way to do
"#pragma once".

Received on 2024-09-23 08:28:28