Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: srand(0) Date: Fri, 09 Jan 2026 17:09:47 -0800 Organization: None to speak of Lines: 52 Message-ID: <87ms2m2rz8.fsf@example.invalid> References: <10ib0ka$3cgil$1@dont-email.me> <10icocl$3u4ua$1@dont-email.me> <867bttph43.fsf@linuxsc.com> <87ikddgkc2.fsf@example.invalid> <10joipc$1jc43$1@dont-email.me> <87344fhghg.fsf@example.invalid> <10jq5u1$23nps$1@dont-email.me> <87tswvnuzx.fsf@example.invalid> <10js023$2nrdh$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sat, 10 Jan 2026 01:09:48 +0000 (UTC) Injection-Info: dont-email.me; posting-host="61927158e26c7463e01824f35fac803d"; logging-data="2969632"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yQrukVCygomdUO2T8ycBh" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:2PCc9iP7BTThHO5x2hbAqrSHd9I= sha1:Qz0aCIPdCts9Ovi+krj+UgSgeKs= Xref: csiph.com comp.lang.c:396331 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 */