4 ms·
frandom-seed is not quite so bad. > The string can either be a number (decimal, octal or hex) or an arbitrary string (in which case it’s converted to a number
by vlovich123 3y ago
frandom-seed is not quite so bad.
> The string can either be a number (decimal, octal or hex) or an arbitrary string (in which case it’s converted to a number by computing CRC32).
> The string should be different for every file you compile.
So basically just pass in the project relative path to the file into random-seed and you'll be fine. It's a shame the guidance doesn't explain why the string should be different because that feels like it could be advice that's not rooted in any technical reality.
__time__ isn't actually that bad as it's an anti-pattern and much better for the build system to inject the build time explicitly as an input macro (if your software needs it for UX purposes).
__FILE__ is the more annoying one but can be solved through fmacro-prefix-map.
- groby_b 3y agoOh, yes, all of those are fixable. It's just a permanent reminder of a lot of bad decisions along the way. And it wouldn't be C++ if a large chunk of the bad decisions wasn't rooted in the preprocessor.