Deutsch   English   Français   Italiano  
<86bju3s5vp.fsf@linuxsc.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: Concatenated if and preprocessor
Date: Fri, 14 Mar 2025 13:40:26 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <86bju3s5vp.fsf@linuxsc.com>
References: <vquuhg$34o8d$2@dont-email.me> <vr15ti$rtjs$1@dont-email.me> <86frjfsgtb.fsf@linuxsc.com> <vr1rni$1q6m7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Fri, 14 Mar 2025 21:40:27 +0100 (CET)
Injection-Info: dont-email.me; posting-host="825d11fa9501a89399e86bed31f148c6";
	logging-data="2137293"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/mjftCQ+TLDAbRktcc1H5ZG2vpBbcj9Yw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:cY36ROZWG5DyqnXzIG8kqvMs3ek=
	sha1:/6yiUzDXyqHD3fWda6EC4NKiD2k=
Bytes: 1971

Richard Harnden <richard.nospam@gmail.invalid> writes:

> On 14/03/2025 16:44, Tim Rentsch wrote:
>
>>    for(  int just_once = 1;  just_once;  just_once = 0  ){
>
> Any reason not to say ...
>
> do {
>     ...
> } while (0);
>
> ... ?

In fact using do/while(0) is what I first wrote.  But then
I thought, oh wait, what if an overzealous compiler gives
a warning because the while() expression is always false? :-/

It's because of examples like this that I am wary of rules
like "enable all warnings" and "treat any warning condition
as an error."  I recently ran across a set of coding standard
rules that included these rules:  not just /some/ warning
conditions, but ALL warning conditions.  I still don't know
if they were literally serious.  (And my understanding is
clang has a -Weverything option, which enables all warning
conditions that clang is able to test for, no matter how
silly.)