C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Revising #pragma once

From: Henry Miller <hank_at_[hidden]>
Date: Mon, 23 Sep 2024 07:51:01 -0500
On Mon, Sep 23, 2024, at 05:55, Gašper Ažman via Std-Proposals wrote:
> HASH DOES NOT WORK. There are reasons for this in this thread, but they
> boil down to this: you'd need to hash the entire reachable filesystem
> because #include's don't resolve the same way depending on where the file
> is accessed from on the filesystem.
>
> #pragma once
> #include "utils.h"
>
> You'll see that header verbatim several times for different libraries in a
> translation unit and you'll miscompile. HASH DOES NOT WORK.
>

I do not believe you are correct there. While you will see the functional parts of the above verbatim, in the real world every header I've seen as a copyright comment and those are typically different. Also different projects have different coding standards for blank lines between said copyright, the #pragma, and the #include. If you account for those in the hash odds are high the files won't match.

Received on 2024-09-23 12:51:23