C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 22 Nov 2023 17:28:59 -0800
On Wednesday, 22 November 2023 04:06:14 PST Frederick Virchanza Gotham via
Std-Proposals wrote:
> So then I was thinking, what if the preprocessor could help us here
> and give us a 128-Bit random number? What if there were to be five new
> macros that would expand as follows:

Why 128-bit? Why not just restrict to 32- and 64-bit? If you need a 128 bits
of randomness, just concatenate 2 or 4 of the lower-sized ones.

> #define __UUID__ 0f234c3ac9ec4d7bab8e2fcac3da8a5c
>
> #define __UUIDstr__ "0f234c3ac9ec4d7bab8e2fcac3da8a5c"

Just use macro/preprocessor stringification. There's no need for this one.

> #define __UUIDstrH__ "0f234c3a-c9ec-4d7b-ab8e-2fcac3da8a5c"

Use a simple constexpr function to mutate the input.

If you want to proceed with this, you may write a paper explaining the
reasoning why a compilation should produce random output (where are all the
papers for the other features you've suggested?). I'm very interested in a
motivation for that. I quite frankly don't see why it should be.

__DATE__ is already too random.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-11-23 01:29:01