C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Get UUID at compile-time from compiler (sort of like __COUNTER__)

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 23 Nov 2023 14:31:05 +0000
On Thu, Nov 23, 2023 at 1:56 PM Lénárd Szolnoki via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I have two concerns:
>
> 1. A similar concern with COUNTER, if it appears in header files it's can be a source of ODR violation.
> 2. Reproducible builds


No. 1 isn't a concern because the __UUID__ will always be different --
you're just asking the compiler for a random 128-Bit number.

As for No. 2, well instead of it being a random 128-Bit number, maybe
it could be a 128-Bit number consisting of:
    (1) 64 bits to somehow identify the file (perhaps a hash of the filename?)
    (2) 32 bits to identify the line number
    (3) 32 bits that increment like how __COUNTER__ does

This would allow us to hit 'Build' a second time and get the same
executable file.

Received on 2023-11-23 14:31:17