Deutsch   English   Français   Italiano  
<vr4a30$3qgtf$2@dont-email.me>

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

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: Concatenated if and preprocessor
Date: Sat, 15 Mar 2025 17:32:32 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <vr4a30$3qgtf$2@dont-email.me>
References: <vquuhg$34o8d$2@dont-email.me> <vr15ti$rtjs$1@dont-email.me>
 <86frjfsgtb.fsf@linuxsc.com> <vr1rni$1q6m7$1@dont-email.me>
 <86bju3s5vp.fsf@linuxsc.com> <87zfhniaij.fsf@nosuchdomain.example.com>
 <vr276s$2307i$1@dont-email.me> <867c4rs0tr.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 15 Mar 2025 17:32:32 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2e4c09e608ddc504bf8fdd389905003a";
	logging-data="4015023"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/iK4rWv03p7/V3j42bn35zwZm43q5HvtU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Evi5Am27HHXJdnVk7YPikGYPhF8=
In-Reply-To: <867c4rs0tr.fsf@linuxsc.com>
Content-Language: en-GB

On 14/03/2025 23:29, Tim Rentsch wrote:
> Richard Harnden <richard.nospam@gmail.invalid> writes:
> 
>> On 14/03/2025 21:10, Keith Thompson wrote:
>>
>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>>
>>>> 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? :-/
>>
>> That would break a lot of macros :)
>>
>>> [...]
>>
>> Hmm, clang with -Weverything is okay with:
>>    do { ... } while (0);
>>
>> But not with:
>>    if ( 0 ) { ... }
>>
>> But it's okay with:
>>    if ( (0) ) { ... }
> 
> These examples illustrate why I have the reaction I do.  That
> plus the lack of clarity as to what the OP's actual requirements
> are explains my decision to use a for() rather than do/while(0).

I think your "for" solution would raise far more questions to any reader 
than idiomatic "do ... while (0)" would, or even if ((0)).  I really 
don't understand your reactions at all.

But I fully agree that it would be a lot easier to give the OP a good 
answer if he explained his requirements and situation better.