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: Thu, 08 Jan 2026 22:46:42 -0800 Organization: None to speak of Lines: 40 Message-ID: <87tswvnuzx.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> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 09 Jan 2026 06:46:43 +0000 (UTC) Injection-Info: dont-email.me; posting-host="acddbd2710fffc9599b4649dda7a064b"; logging-data="2213150"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mlfsZ63GG1TKNM9SDfEQM" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:PPirGY6xkBc8rGI9Ef2dLqNnY8g= sha1:GAQBifRNG23og8URBnJi4fLTP1I= Xref: csiph.com comp.lang.c:396315 Michael Sanders writes: > On Thu, 08 Jan 2026 14:44:27 -0800, Keith Thompson wrote: >> Michael Sanders writes: [...] >>> So then clang would use: >>> >>> #ifdef __OpenBSD__ >>> srand_deterministic(seed); >>> #else >>> srand(seed); >>> #endif >>> >>> But I don't know (yet) that gcc does as well under OpenBSD. >> >> I don't know what you mean when you say that clang "would use" >> that code. >> >> I'm not aware that either clang or gcc uses random numbers >> internally. I don't know why they would. > > Well, I meant the macro itself is (I'm guessing) probably defined > by clang since its the default compiler. You mean the macro __OpenBSD__? Yes, that and other similar macros are predefined by the compiler, which is configured for each OS. gcc on OpenBSD also predefines it. (I don't know whether it's predefined by the preprocessor directly or by some header that's included implicitly. That doesn't really matter.) Compilers on other platforms will not predefine __OpenBSD__. 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? [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */