From: Keith.S.Thompson+u@gmail.com
Michael Sanders writes:
> On Thu, 08 Jan 2026 22:46:42 -0800, Keith Thompson wrote:
>> But your original statement implied that clang would *use* that
>> particular piece of code, which didn't make much sense. Were you
>> just asking about how the __OpenBSD__ macro is defined, without
>> reference to srand?
>
> Well, under OpenBSD I plan on using:
>
> #ifdef __OpenBSD__
> srand_deterministic(seed);
> #else
> srand(seed);
> #endif
>
> But what I was asking is whether or not gcc would recognize
> the __OpenBSD__ macro (why wouldn't I'm assuming) since clang
> is the default compiler.
OK.
Do you understand that your original question was unclear?
You said that "clang would use" the quoted 5-line code snippet,
and asked whether "gcc does as well". It's not clang or gcc that
would use that code. It would be used by a programmer writing code
to be compiled with clang or gcc.
I understand now what you meant. I'd like to be sure that you
understand the problem with the question as you originally wrote it.
I have clang 19.1.7 and gcc 13.2.0 installed on OpenBSD 7.8, and
both predefine the macro __OpenBSD__.
> But also about srand()... you've got me really wondering why
> OpenBSD would deviate from the standard as they have. I get
> that the those folks disagree because its deterministic, but
> its the accepted standard to be deterministic with srand().
>
> Only speaking for myself here, rather than srand_deterministic()
> and srand() (that's not deterministic under OpenBSD) it
> would've made more sense to've implemented srand_non_deterministic()
> and left srand() alone. That design decision on their part only
> muddies the waters in my thinking. Live & learn =)
I don't know why they made that decision. It was clearly deliberate.
I agree that adding an srand_non_deterministic() function would
have been better.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
--- SoupGate-Win32 v1.05
* Origin: you cannot sedate... all the things you hate (1:229/2)
|